7 digit decimal number

Lyle Ramshaw ramshawapa.dec.com
Sat Apr 10 17:50:28 PDT 1999


Fred, you were almost there!  The number 1e28 is such an example.
Converting 10^28 to floating-point binary, we get

 1.00000010011111100111001011110001111100010010100000010011000010001 x 2^93,
                         ^

where the caret marks the 24th bit.  The tail to the right of the
caret is slightly less than 1/2, so rounding to the nearest
24-bit-binary number gives

 1.00000010011111100111001 x 2^93.

Converting back to decimal, that is the integer

             9999999442119689768320106496,
                   ^

the caret here marking the 7th digit.  Rounding to the nearest
7-digit-decimal number thus gives

       9.999999e27.

Lyle




More information about the Numeric-interest mailing list