Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #29661
| References | <505ca3e9$0$29981$c3e8da3$5496439d@news.astraweb.com> |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | 2012-09-21 12:13 -0600 |
| Subject | Re: Exact integer-valued floats |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1027.1348251221.27098.python-list@python.org> (permalink) |
On Fri, Sep 21, 2012 at 11:29 AM, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > The question is, what is the largest integer number N such that every > whole number between -N and N inclusive can be represented as a float? > > If my tests are correct, that value is 9007199254740992.0 = 2**53. > > Have I got this right? Is there a way to work out the gap between one > float and the next? That looks mathematically correct. The "gap" between floats is the equivalent of a difference of 1 bit in the significand. For a floating point number represented as (sign * c * 2 ** q), where c is an integer, the gap between floats is equal to 2 ** q. There are 53 bits of precision in a double-precision float (technically an implicit 1 followed by 52 bits), so q becomes greater than 0 at 2 ** 53. Cheers, Ian
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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