## [squeak-dev] Re: [Vm-dev] Re: Float hierarchy for 64-bit Spur

Bert Freudenberg bert at freudenbergs.de
Mon Nov 24 10:51:06 UTC 2014

```On 24.11.2014, at 05:09, David T. Lewis <lewis at mail.msen.com> wrote:
> (*) As a former field service engineer for Harris Computer Systems, I still
> consider the 48-bit floating point format of the H800 series to be superior to
> the awkward compromises of 32-bit and 64-bit floating point representations ;-)
> See pages 2-2 and 6-1 of the manual for descriptions of the floating point data
> formats (I think I have a paper copy of this moldering away in my basement).
>
> http://bitsavers.informatik.uni-stuttgart.de/pdf/harris/0830007-000_Series_800_Reference_Man_Aug79.pdf

Oh, I got excited for a moment there, thinking that maybe this could be the origin of Smalltalk-78's weird 48 bit floating point format. But it's completely different. I had to reverse-engineer it because Dan could not remember (only later we got a printout of the VM's 8086 assembly source code). It's optimized for a software implementation with the mantissa on a 16-bit word boundary. Not sure why the exponent's sign bit is in the LSB though. But 16 bits of exponent, can you imagine the range? Luckily there were no insanely large instances in the snapshot. They get converted to modern floats when parsing the original object space dump:

wordsAsFloat: function() {
// layout of NoteTaker Floats (from MSB):
// 15 bits exponent in two's complement without bias, 1 bit sign
// 32 bits mantissa including its highest bit (which is implicit in IEEE 754)
if (this.words[1] == 0) return 0.0; // if high-bit of mantissa is 0, then it's all zero
var nt0 = this.words[0], nt1 = this.words[1], nt2 = this.words[2],
ntExponent = nt0 >> 1, ntSign = nt0 & 1, ntMantissa = (nt1 & 0x7FFF) << 16 | nt2, // drop high bit of mantissa
ieeeExponent = (ntExponent + 1022) & 0x7FF, // IEEE: 11 bit exponent, biased
ieee = new DataView(new ArrayBuffer(8));
// IEEE is 1 sign bit, 11 bits exponent, 53 bits mantissa omitting the highest bit (which is always 1, except for 0.0)
ieee.setInt32(0, ntSign << 31 | ieeeExponent << (31-11) | ntMantissa >> 11); // 20 bits of ntMantissa
ieee.setInt32(4, ntMantissa << (32-11)); // remaining 11 bits of ntMantissa, rest filled up with 0
// why not use setInt64()? Because JavaScript does not have 64 bit ints
return ieee.getFloat64(0);
}

- Bert -

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4142 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20141124/da0704ab/smime.bin
```

More information about the Squeak-dev mailing list