3.2*2 is 9.6 ... or maybe it isn't?

Amos Anderson amosanderson at gmail.com
Thu Jun 25 20:18:08 CEST 2009


I think what your experiencing is addressed on this page...

http://docs.python.org/tutorial/floatingpoint.html

... it has to do with the binary representation of the numbers.

On Thu, Jun 25, 2009 at 1:04 PM, Bojan Sudarevic <bojan at sudarevic.com>wrote:

> Hi,
>
> I'm PHP developer and entirely new to Python. I installed it (version
> 2.5.2, from Debian repos) today on the persuasion of a friend, who is a
> Python addict.
>
> The first thing I typed into it was 3.2*3 (don't ask why I typed *that*,
> I don*t know, I just did). And the answer wasn't 9.6.
>
> Here it is:
>
> >>> 3.2*3
> 9.6000000000000014
>
> So I became curious...
>
> >>> 3.21*3
> 9.629999999999999
> >>> (3.2*3)*2
> 19.200000000000003
> ... and so on ...
>
> After that I tried Windows version (3.1rc2), and...
>
> >>> 3.2*3
> 9.600000000000001
>
> I wasn't particularly good in math in school and university, but I'm
> pretty sure that 3.2*3 is 9.6.
>
> Cheers,
> Bojan
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090625/bf98aa8a/attachment.html>


More information about the Python-list mailing list