Exact integer-valued floats
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Fri Sep 21 21:36:59 EDT 2012
On Fri, 21 Sep 2012 15:23:41 -0700, Paul Rubin wrote:
> Steven D'Aprano <steve+comp.lang.python at pearwood.info> writes:
>> Have I got this right? Is there a way to work out the gap between one
>> float and the next?
>
> Yes, 53-bit mantissa as people have mentioned. That tells you what ints
> can be exactly represented. But, arithmetic in some situations can have
> a 1-ulp error. So I wonder if it's possible that if n is large enough,
> you might have something like n+1==n even if the integers n and n+1 have
> distinct floating point representations.
I don't think that is possible for IEEE 754 floats, where integer
arithmetic is exact. But I'm not entirely sure, which is why I asked.
For non IEEE 754 floating point systems, there is no telling how bad the
implementation could be :(
--
Steven
More information about the Python-list
mailing list