Python math is off by .000000000000045
Tim Wintle
tim.wintle at teamrubber.com
Sat Feb 25 14:08:47 EST 2012
On Sat, 2012-02-25 at 09:56 -0800, Tobiah wrote:
> > For every floating point
> > number there is a corresponding real number, but 0% of real numbers
> > can be represented exactly by floating point numbers.
>
> It seems to me that there are a great many real numbers that can be
> represented exactly by floating point numbers. The number 1 is an
> example.
>
> I suppose that if you divide that count by the infinite count of all
> real numbers, you could argue that the result is 0%.
It's not just an argument - it's mathematically correct.
The same can be said for ints representing the natural numbers, or
positive integers.
However, ints can represent 100% of integers within a specific range,
where floats can't represent all real numbers for any range (except for
the empty set) - because there's an infinate number of real numbers
within any non-trivial range.
Tim
More information about the Python-list
mailing list