Float Question

Tim Olson tim at jumpnet.com
Sun Jan 3 15:49:38 UTC 1999


Richard Harmon writes:

[exponent field]
>        11 bits     - value minus 1023 (16r3FF) to produce an exponent
>                        of -1022 (-16r3FE) through +1023 (16r3FF)
>                    - 16r000 reserved for Float zero (mantissa is ignored)
>                    - 16r7FF reserved for Float underflow/overflow (mantissa
>is ignored)

These are not quite right; they should be:

          11 bits   - value minus 1023 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

>        fmax Definition: Report the largest value allowed by the
>characterized floating point object representation. This satisfies the
>ISO/IEC 10967 floating point characterization requirement fmax, and is 
>equal to:
>
>                (1 - (self radix raisedTo: self precision negated))
>                * self radix raisedTo: self emax


I think you forgot some parenthesis, here; it should be:

     (1 - (self radix raisedTo: self precision negated)) *
          (self radix raisedTo: self emax)


>        precision (52) 

[should be 53, there are 53 bits of precision including the hidden '1' 
bit]


>        emax (1023)

[should be 1024]


With the correct values, I get:

((1 - (2 raisedTo: 53 negated)) * (2 raisedTo: 1024)) asFloat

     => 1.797693134862315e308



     -- tim





More information about the Squeak-dev mailing list