code not true?
Remco Gerlich
scarblac-spamtrap at pino.selwerd.nl
Sat Apr 22 08:12:18 EDT 2000
jeff_islay at my-deja.com wrote in comp.lang.python:
> Why does the second example return false?
>
> >>> print 7.0 == 7
> 1
> >>> print (.07 * 100) == 7
> 0
Floating point number on a binary computer are strange. They're not that
accurate. 0.07 * 100 != 7.0.
Try
>>> 0.07*100 == 7.0
0
>>> 0.07*100 - 7.0
8.881784197e-16
In Python 1.6, the interpreter doesn't try to hide this:
>>> 0.07*100
7.0000000000000009
For way too much info, look for old posts on this group by Tim Peters with
the words "floating point".
--
Remco Gerlich, scarblac at pino.selwerd.nl
This is no way to be
Man ought to be free -- Ted Bundy
That man should be me
More information about the Python-list
mailing list