Decimals not equalling themselves (e.g. 0.2 = 0.2000000001)
gagsl-py2 at yahoo.com.ar
Tue Aug 5 19:37:47 CEST 2008
En Tue, 05 Aug 2008 11:50:43 -0300, schinckel <matt at schinckel.net> escribió:
> I had a class today which dealt with Decimal <-> IEE754 conversion,
> whilst 0.1 was an example that was converted, and a representation was
> generated, no mention was made of the precision issue.
> I'm hoping that it was just that we ran out of time, and the lecturer
> will discuss it in detail next time.
Presumably you encountered that 0.1 (decimal) = 0.000110011001100... (binary), and as you can see it has infinite periodic bits. IEEE754 stores only a finite number of bits for the mantissa, all the remaining (infinite) bits are dropped; a representation error is unavoidable.
More information about the Python-list