Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #29735

Re: Exact integer-valued floats

From Nobody <nobody@nowhere.com>
Subject Re: Exact integer-valued floats
Date 2012-09-22 11:19 +0100
Message-Id <pan.2012.09.22.10.19.32.821000@nowhere.com>
Newsgroups comp.lang.python
References <505ca3e9$0$29981$c3e8da3$5496439d@news.astraweb.com> <7xzk4j6mmq.fsf@ruckus.brouhaha.com>
Organization Zen Internet

Show all headers | View raw


On Fri, 21 Sep 2012 15:23:41 -0700, Paul Rubin wrote:

> Steven D'Aprano <steve+comp.lang.python@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.

Not for IEEE-754. Or for any sane implementation, for that matter. OTOH,
you can potentially get n != n due to the use of extended precision for
intermediate results.

For IEEE-754, addition, subtraction, multiplication, division, remainder
and square root are "exact" in the sense that the result is as if the
arithmetic had been performed with an infinite number of bits then rounded
afterwards. For round-to-nearest, the result will be the closest
representable value to the exact value.

Transcendental functions suffer from the "table-maker's dilemma", and the
result will be one of the two closest representable values to the exact
value, but not necessarily *the* closest.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Exact integer-valued floats Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-21 17:29 +0000
  Re: Exact integer-valued floats Ian Kelly <ian.g.kelly@gmail.com> - 2012-09-21 12:13 -0600
  Re: Exact integer-valued floats Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2012-09-21 22:47 +0300
  Re: Exact integer-valued floats Nobody <nobody@nowhere.com> - 2012-09-21 20:59 +0100
  Re: Exact integer-valued floats Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-09-21 16:26 -0400
    Re: Exact integer-valued floats Hans Mulder <hansmu@xs4all.nl> - 2012-09-21 23:04 +0200
      Re: Exact integer-valued floats Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-09-21 20:54 -0400
  Re: Exact integer-valued floats Alister <alister.ware@ntlworld.com> - 2012-09-21 21:14 +0000
  Re: Exact integer-valued floats Paul Rubin <no.email@nospam.invalid> - 2012-09-21 15:23 -0700
    Re: Exact integer-valued floats Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-22 01:36 +0000
      Re: Exact integer-valued floats Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-09-22 01:01 -0400
        Re: Exact integer-valued floats Tim Roberts <timr@probo.com> - 2012-09-22 14:05 -0700
          Re: Exact integer-valued floats Dave Angel <d@davea.name> - 2012-09-22 19:06 -0400
            Re: Exact integer-valued floats Hans Mulder <hansmu@xs4all.nl> - 2012-09-23 09:45 +0200
          Re: Exact integer-valued floats wrw@mac.com - 2012-09-24 11:29 -0400
    Re: Exact integer-valued floats Nobody <nobody@nowhere.com> - 2012-09-22 11:19 +0100

csiph-web