1== 1 is False?

Thomas Nücker thomas.nuecker at web.de
Tue Jun 24 04:34:12 EDT 2003


Gerhard Häring <gh at ghaering.de> wrote in message news:<mailman.1056119630.21165.python-list at python.org>...
> delphiro wrote:
> > [...] If I print out the values I get something like 2.260212 <= 2.260212 and 2.260212 >= 2.260212 is NOT true.
> > 
> > What's wrong?
> 
> Your float values might not be what they look like.
> 
> It makes a difference wether you use str() or repr() to convert them to 
> strings, for example:
> 
> #v+
>  >>> 2/3.0
>  0.66666666666666663
>  >>> print 2/3.0
> 0.666666666667
> #v-
> 
> -- Gerhard

What do i have to do, if i need "more" exactness? 
I have for example the problem with the representation of 2.3 or 2.7:
>>> 2.3
2.2999999999999998
>>> 2.7
2.7000000000000002
This is a really strange behaviour!

Thomas




More information about the Python-list mailing list