code not true?
Moshe Zadka
moshez at math.huji.ac.il
Sun Apr 23 01:00:21 EDT 2000
On Sat, 22 Apr 2000, John W. Baxter wrote:
> > > >>> 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!
> >
> Not quite. No number of bits is sufficient to represent .07 exactly in
> the typical (and IEEE standard) representation.
Yes, but enough bits could make sure that 0.07*100 is indistinguishable
from 7.0
But I agree with the point -- floats are evil. Very very evil. In fact,
I wouldn't mind at all if there was some specific command-line flag to the
interpreter to enable floats.
--
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