[Vm-dev] Re: [squeak-dev] Re: Float hierarchy for 64-bit Spur
Eliot Miranda
eliot.miranda at gmail.com
Fri Nov 21 17:59:02 UTC 2014
On Fri, Nov 21, 2014 at 4:47 AM, Bert Freudenberg <bert at freudenbergs.de>
wrote:
> On 21.11.2014, at 02:51, Eliot Miranda <eliot.miranda at gmail.com> wrote:
>
> > Hi All,
> >
> > 64-bit Spur can usefully provide an immediate float, a 61-bit subset
> of the ieee double precision float. The scheme steals bits from the
> mantissa to use for the immediate's 3-bit tag pattern. So values have the
> same precision as ieee doubles, but can only represent the subset with
> exponents between 10^-38 and 10^38, the single-precision range.
>
> This is worded confusingly. It sounds like the mantissa has 3 bits less,
> which would make it less precise.
>
It's not worded confusingly, it's just plain wrong :-/. Let me try again...
64-bit Spur can usefully provide an immediate float, a 61-bit subset of the
ieee double precision float. The scheme steals 3 bits from the exponent to
use for the immediate's 3-bit tag pattern. So values have the same
precision as ieee doubles, but can only represent the subset with exponents
between 10^-38 and 10^38, the single-precision range.
Here's the representation:
[8 bit exponent][52 bit mantissa][1 bit sign][3 bit tag]
This has the advantage that +/- zero are the only immediate float values
that are less than or equal to fifteen. So to convert to a float:
- shift away tags
[000][8 bit exponent][52 bit mantissa][1 bit sign]
- if > 1 (i.e. non-zero)
add exponent offset:
[11 bit exponent][52 bit mantissa][sign bit]
- rotate by -1
[sign bit][11 bit exponent][52 bit mantissa]
And to encode:
- rotate by 1
[11 bit exponent][52 bit mantissa][sign bit]
- if > 1
subtract exponent offset
fail if <= 0
test against max value, fail if too big
- shift by 3 and add tag bits:
[8 bit exponent][52 bit mantissa][1 bit sign][3 bit tag]
Here is how I understood it: The mantissa is stored with its full 52 bits
> of precision (*). But only the lower 8 bits of the 11-bit exponent are
> stored. If the upper 3 bits of the exponent are needed, then a boxed float
> is created.
I guess I know what you meant, that it is the 3 lowest significant bits in
> an oop which are used for tagging immediate objects, and in an IEEE double
> that is part of the mantissa. But these 3 bits are not lost, but moved
> elsewhere (namely where the 3 highest significant bits of the exponent used
> to be stored).
>
> Did I understand correctly? You haven't pushed the code yet so I couldn't
> verify.
>
Yes, of course :-)
> - Bert -
>
> (*) http://en.wikipedia.org/wiki/Double-precision_floating-point_format
>
--
best,
Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20141121/1290115b/attachment.htm
More information about the Vm-dev
mailing list