Float class comment

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Float class comment

Eliot Miranda-2
Hi All,

    who wrote the Float class comment?  Two things,

- first the comment mentions "I" and thanks several people, but there is no comment stamp to reveal the author.  It would be lovely if the author could "sign" this comment

- second, there seems to be a minor error (but I'm no expert), the comment states

"It may help you to know that the basic format is...
sign 1 bit
exponent 11 bits with bias of 1023 (16r3FF) to produce an exponent
in the range -1023 .. +1024
- 16r000:
significand = 0: Float zero
significand ~= 0: Denormalized number (exp = -1024, no hidden '1' bit)
- 16r7FF:
significand = 0: Infinity
significand ~= 0: Not A Number (NaN) representation
mantissa 53 bits, but only 52 are stored (20 in the first word, 32 in the second).  This is because a normalized mantissa, by definition, has a 1 to the right of its floating point, and IEEE-754 omits this redundant bit to gain an extra bit of precision instead.  People talk about the mantissa without its leading one as the FRACTION, and with its leading 1 as the SIGNFICAND."

But if the significand has a leading zero then surely the section in the middle should read

sign 1 bit
exponent 11 bits with bias of 1023 (16r3FF) to produce an exponent
in the range -1023 .. +1024
- 16r000:
mantissa = 0: Float zero
mantissa ~= 0: Denormalized number (exp = -1024, no hidden '1' bit)
- 16r7FF:
mantissa = 0: Infinity
mantissa ~= 0: Not A Number (NaN) representation

Right?
--
best,
Eliot


Reply | Threaded
Open this post in threaded view
|

Re: Float class comment

Nicolas Cellier

Float fminNormalized significand 1.0
Float fminNormalized exponent -1022

Float fminNormalized predecessor significand 1.9999999999999996
Float fminNormalized predecessor exponent -1023

But the significand only has 52 bits in this case of underflow.
Gradual underflow is removing the leading 1, so that one should better be written like:
Float fminNormalized predecessor = 2r0.1111111111111111111111111111111111111111111111111111e-1022
and that means that the exponent is still -1022 for gradual underflow (aka Float emin)...

And the smallest Float above zero is :
Float fmin significand 1.0
Float fmin exponent -1074
or
Float fmin = 2r0.0000000000000000000000000000000000000000000000000001e-1022

Nicolas

2014-11-25 18:42 GMT+01:00 Eliot Miranda <[hidden email]>:
Hi All,

    who wrote the Float class comment?  Two things,

- first the comment mentions "I" and thanks several people, but there is no comment stamp to reveal the author.  It would be lovely if the author could "sign" this comment

- second, there seems to be a minor error (but I'm no expert), the comment states

"It may help you to know that the basic format is...
sign 1 bit
exponent 11 bits with bias of 1023 (16r3FF) to produce an exponent
in the range -1023 .. +1024
- 16r000:
significand = 0: Float zero
significand ~= 0: Denormalized number (exp = -1024, no hidden '1' bit)
- 16r7FF:
significand = 0: Infinity
significand ~= 0: Not A Number (NaN) representation
mantissa 53 bits, but only 52 are stored (20 in the first word, 32 in the second).  This is because a normalized mantissa, by definition, has a 1 to the right of its floating point, and IEEE-754 omits this redundant bit to gain an extra bit of precision instead.  People talk about the mantissa without its leading one as the FRACTION, and with its leading 1 as the SIGNFICAND."

But if the significand has a leading zero then surely the section in the middle should read

sign 1 bit
exponent 11 bits with bias of 1023 (16r3FF) to produce an exponent
in the range -1023 .. +1024
- 16r000:
mantissa = 0: Float zero
mantissa ~= 0: Denormalized number (exp = -1024, no hidden '1' bit)
- 16r7FF:
mantissa = 0: Infinity
mantissa ~= 0: Not A Number (NaN) representation

Right?
--
best,
Eliot






Reply | Threaded
Open this post in threaded view
|

Re: [Pharo-dev] Float class comment

Marcus Denker-4
In reply to this post by Eliot Miranda-2
I added an issue tracker entry

        14536 Float class comment
                https://pharo.fogbugz.com/f/cases/14536


> On 25 Nov 2014, at 18:42, Eliot Miranda <[hidden email]> wrote:
>
> Hi All,
>
>     who wrote the Float class comment?  Two things,
>
> - first the comment mentions "I" and thanks several people, but there is no comment stamp to reveal the author.  It would be lovely if the author could "sign" this comment
>
> - second, there seems to be a minor error (but I'm no expert), the comment states
>
> "It may help you to know that the basic format is...
> sign 1 bit
> exponent 11 bits with bias of 1023 (16r3FF) to produce an exponent
> in the range -1023 .. +1024
> - 16r000:
> significand = 0: Float zero
> significand ~= 0: Denormalized number (exp = -1024, no hidden '1' bit)
> - 16r7FF:
> significand = 0: Infinity
> significand ~= 0: Not A Number (NaN) representation
> mantissa 53 bits, but only 52 are stored (20 in the first word, 32 in the second).  This is because a normalized mantissa, by definition, has a 1 to the right of its floating point, and IEEE-754 omits this redundant bit to gain an extra bit of precision instead.  People talk about the mantissa without its leading one as the FRACTION, and with its leading 1 as the SIGNFICAND."
>
> But if the significand has a leading zero then surely the section in the middle should read
>
> sign 1 bit
> exponent 11 bits with bias of 1023 (16r3FF) to produce an exponent
> in the range -1023 .. +1024
> - 16r000:
> mantissa = 0: Float zero
> mantissa ~= 0: Denormalized number (exp = -1024, no hidden '1' bit)
> - 16r7FF:
> mantissa = 0: Infinity
> mantissa ~= 0: Not A Number (NaN) representation
>
> Right?
> --
> best,
> Eliot