3.2*2 is 9.6 ... or maybe it isn't?
paul.nospam at rudin.co.uk
Thu Jun 25 14:32:12 EDT 2009
Bojan Sudarevic <bojan at sudarevic.com> writes:
> 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:
> So I became curious...
> ... and so on ...
> After that I tried Windows version (3.1rc2), and...
> I wasn't particularly good in math in school and university, but I'm
> pretty sure that 3.2*3 is 9.6.
This is almost certainly nothing to do with python per se, but the
floating point implementation of your hardware. Floating point
arithmetic on computers is not accurate to arbitrary precision. If you
want such precision use a library that supports it or make you own
translations to and from appropriate integer sums (but it's going to be
More information about the Python-list