Python math is off by .000000000000045
invalid at invalid.invalid
Wed Feb 22 21:48:34 CET 2012
On 2012-02-22, Alec Taylor <alec.taylor6 at gmail.com> wrote:
> Simple mathematical problem, + and - only:
> That's wrong.
Oh good. We haven't have this thread for several days.
> -60.95 aka (-(1219/20))
> Is there a reason Python math is only approximated?
Python uses binary floating point with a fixed size (64 bit IEEE-754
on all the platforms I've ever run across). Floating point numbers
are only approximations of real numbers. For every floating point
number there is a corresponding real number, but 0% of real numbers
can be represented exactly by floating point numbers.
> - Or is this a bug?
No, it's how floating point works.
If you want something else, then perhaps you should use rationals or
Grant Edwards grant.b.edwards Yow! What I want to find
at out is -- do parrots know
gmail.com much about Astro-Turf?
More information about the Python-list