Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'bits': 0.07; 'commonly': 0.09; 'correct,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'sep': 0.09; 'encoding': 0.15; '8-bit': 0.16; 'digits.': 0.16; 'ignores': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'integer': 0.17; 'tests': 0.18; 'bit': 0.21; 'affected': 0.22; 'runs': 0.22; 'somewhere': 0.24; 'possibility': 0.27; 'question': 0.27; 'header:X-Complaints- To:1': 0.28; "d'aprano": 0.29; 'decimal': 0.29; 'implied': 0.29; 'represented': 0.29; 'steven': 0.29; 'could': 0.32; 'shift': 0.33; 'url:home': 0.33; 'to:addr:python-list': 0.33; 'largest': 0.35; 'machines': 0.35; 'something': 0.35; 'received:org': 0.36; 'charset:us-ascii': 0.36; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'skip:" 10': 0.40; 'subject:-': 0.40; 'header:Received:5': 0.40; 'remove': 0.61; 'leading': 0.61; 'between': 0.63; 'more': 0.63; 'power': 0.74; 'inclusive': 0.84; 'dennis': 0.91; 'received:108': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: Exact integer-valued floats Date: Fri, 21 Sep 2012 16:26:26 -0400 Organization: > Bestiaria Support Staff < References: <505ca3e9$0$29981$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 108.79.219.15 X-Newsreader: Forte Agent 3.3/32.846 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1348259186 news.xs4all.nl 6934 [2001:888:2000:d::a6]:38899 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:29676 On 21 Sep 2012 17:29:13 GMT, Steven D'Aprano declaimed the following in gmane.comp.python.general: > > 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? > Single precision commonly has 7 significant (decimal) digits. Double precision runs somewhere between 13 and 15 (decimal) significant digits > If my tests are correct, that value is 9007199254740992.0 = 2**53. > For an encoding of a double precision using one sign bit and an 8-bit exponent, you have 53 bits available for the mantissa. This ignores the possibility of an implied msb in the mantissa (encodings which normalize to put the leading 1-bit at the msb can on some machines remove that 1-bit and shift the mantissa one more place; effectively giving a 54-bit mantissa). Something like an old XDS Sigma-6 used non-binary exponents (exponent was in power of 16 <> 2^4) and used "non-normalized" mantissa -- the mantissa could have up to three leading 0-bits); this affected the decimal significance... -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/