floating point in 2.0

Aahz Maruch aahz at panix.com
Tue Jun 5 10:21:32 EDT 2001


In article <slrn9hpc2i.7o0.scarblac at pino.selwerd.nl>,
Remco Gerlich <scarblac at pino.selwerd.nl> wrote:
>
>The way they're stored hasn't changed, it's just that 2.0 doesn't lie
>anymore when writing the repr() of a float. This is how the floats are
>represented internally, there is no exact binary representation for any of
>them except 0.5.

Actually, 2.0 *still* lies:

>>> 0.1
0.10000000000000001
>>> '%.55f' % 0.1
'0.1000000000000000055511151231257827021181583404541015625'

It just lies less than it used to.
-- 
                      --- Aahz  <*>  (Copyright 2001 by aahz at pobox.com)

Androgynous poly kinky vanilla queer het Pythonista   http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

"Do not taunt happy fun for loops. Do not change lists you are looping over."
--Remco Gerlich, comp.lang.python



More information about the Python-list mailing list