rounding errors?

Jason Mobarak jason at __no_spam__mobarak.name
Sat Jul 3 06:19:27 CEST 2004


http://docs.python.org/tut/node15.html

todd wrote:
> Hi, 
> I've just started using Python, and am having an extraordinary experience.
> One thing worries me, however,  I'm planning on doing some mathematical
> research with Python, and it appears that it does funny thing with
> floating point numbers..  Maybe It's superficial, but here's what I'm
> getting,using the interpreter..
> 
>>>>.31
> 
> 0.31
> 
>>>>.32
> 
> 0.32000000000000001
> 
>>>>.33
> 
> 0.33000000000000002
> 
>>>>.34
> 
> 0.34000000000000002
> 
>>>>.35
> 
> 0.34999999999999998
> 
>>>>.21
> 
> 0.20999999999999999
> 
> Now, I realize that this is really small errors.. Does anybody have an
> explanation why Python picks up or loses these?
> Thanks
> Todd



More information about the Python-list mailing list