Really basic problem

Andreas Tawn andreas.tawn at ubisoft.com
Mon Oct 8 09:21:14 EDT 2007


> > I guess this means that Python has some concept of "close 
> enough", but
> > I'll have to defer to someone more knowledgeable to explain that.
> 
> No, not really, except in the sense that any floating point 
> calculation 
> will be necessarily imprecise in that sense.
[snip]
> So typing 0.3 is the same as typing 0.29999999999999999 or 
> 0.30000000000000001 as far as floating point binary values 
> are concerned.
> 
> (Although note that these results are platform dependent. 
> Your mileage 
> may vary.)
> 
> -- 
> Steven
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 

After some caffeine and a head-smack, I realise that you're absolutely
right and I just made the same mistake as the OP (doh).

It does demonstrate just how sneaky floating point representations are
though.

Cheers,

Andreas Tawn
Lead Technical Artist
Ubisoft Reflections



More information about the Python-list mailing list