floating point in 2.0

Nick Perkins nperkins7 at home.com
Sun Jun 10 04:33:00 EDT 2001


"Chris Barker" <chrishbarker at home.net> wrote:
> 1 / 10 takes only one digit to represent accurately in base ten but
> takes as many bits as you have to not precisly represent in binary. A
> similar situation can be true in the reverse direction.

decimal   ->    binary
0.1             0.0001010101010... or whatever it is..

but..
The reverse condition can not happen.
Every n-digit binary float can be exactly represented by n decimal digits.

binary    ->    decimal
0.1             0.5
0.01            0.25
0.001           0.125
0.0001          0.0625
0.00001         0.03125
0.000001        0.015625
...             ...

Adding up any combination of these rows to produce any binary number, still
produces a decimal number of the same length as the binary number.

That is why decimal numbers are more powerful than binary, because for any
given length, the set of numbers representable in decimal is a superset of
those representable in binay.






More information about the Python-list mailing list