Python math is off by .000000000000045

Terry Reedy tjreedy at
Sat Feb 25 16:05:05 EST 2012

On 2/25/2012 12:56 PM, Tobiah wrote:

> 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.

Binary floats can represent and integer and any fraction with a 
denominator of 2**n within certain ranges. For decimal floats, 
substitute 10**n or more exactly, 2**j * 5**k since if J < k,
n / (2**j * 5**k) = (n * 2**(k-j)) / 10**k and similarly if j > k.

Terry Jan Reedy

More information about the Python-list mailing list