code not true?

Moshe Zadka moshez at math.huji.ac.il
Sat Apr 22 08:25:38 EDT 2000


On Sat, 22 Apr 2000 jeff_islay at my-deja.com wrote:

> Why does the second example return false?
> 
> >>> print 7.0 == 7
> 1
> >>> print (.07 * 100) == 7
> 0

Because computers represent floats with too little bits.
Never ever compare two floats for equality!

--
Moshe Zadka <mzadka at geocities.com>. 
http://www.oreilly.com/news/prescod_0300.html
http://www.linux.org.il -- we put the penguin in .com





More information about the Python-list mailing list