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


Groups > comp.lang.python > #83387

Re: where in Nan defined

Path csiph.com!usenet.pasdenom.info!news.franciliens.net!fdn.fr!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'sufficient': 0.05; 'float': 0.07; 'overflow': 0.09; 'sure,': 0.09; 'cc:addr:python- list': 0.11; 'python': 0.11; 'jan': 0.12; 'exponent': 0.16; 'fallback': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'inf': 0.16; 'infinity,': 0.16; 'mine.': 0.16; 'nan': 0.16; 'portable': 0.16; 'subject:where': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'rules': 0.22; 'cc:addr:python.org': 0.22; 'fairly': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'second': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'constant': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'quite': 0.32; 'entirely': 0.33; 'fri,': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'shorter': 0.36; 'should': 0.36; 'represent': 0.38; 'pm,': 0.38; 'expect': 0.39; 'sure': 0.39; 'skip:u 10': 0.60; 'first': 0.61; '2015': 0.84; 'nice,': 0.84; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=NAMzMNaT3DFjHyvSkndxuL1RH/6os2UBDpnSRnKk5Xk=; b=HWszia0XzMiZKcMiiKN+Gab4JM9drEal8Th3UpkHvqVLMGnffr1lH1yOEpIQ39J6D/ a/IPsQdzpZ8NbRVh6VYXbI/IEW7mvapwXuN4fw67Gr20HAe0nWGjEpX/FTRHPGsTcYsz V/vSon8eu4J+pCvySheDbb6EZ2l9krJpqpPzlWU+mwIwZPR9YrMTNCYAa2v/ajlNKKnA wJKs+NadDT0tny8o7oiWZ2trh3fjSP9igo+t/DSkIaIhpl95+e8N+6Mw0XmtLbWJrqet fhPJ8BrHpqwL5m/IkYbJXSJcyZ40Enm9rLb+S6undf7G/0Ac6yFzcjlSECmHFaHE62Ax dOCw==
MIME-Version 1.0
X-Received by 10.42.52.200 with SMTP id k8mr11079207icg.26.1420769221928; Thu, 08 Jan 2015 18:07:01 -0800 (PST)
In-Reply-To <54af32f4$0$12990$c3e8da3$5496439d@news.astraweb.com>
References <m8m3et$1gu$2@speranza.aioe.org> <mailman.17472.1420727095.18130.python-list@python.org> <87zj9te3tz.fsf@elektro.pacujo.net> <qotk30xjpib.fsf@ruuvi.it.helsinki.fi> <mailman.17477.1420729115.18130.python-list@python.org> <54af32f4$0$12990$c3e8da3$5496439d@news.astraweb.com>
Date Fri, 9 Jan 2015 13:07:01 +1100
Subject Re: where in Nan defined
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.17493.1420769224.18130.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1420769224 news.xs4all.nl 2873 [2001:888:2000:d::a6]:52297
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:83387

Show key headers only | View raw


On Fri, Jan 9, 2015 at 12:46 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> Chris Angelico wrote:
>
>> On Fri, Jan 9, 2015 at 1:50 AM, Jussi Piitulainen
>> <jpiitula@ling.helsinki.fi> wrote:
>>>    >>> 0*1e400
>>>    nan
>>
>> Nice, that's shorter than mine.
>
> I'm not entirely sure, but I suspect that 0*1e400 may not be quite as
> portable as your inf-inf. By the rules of IEEE-754 arithmetic, inf-inf has
> to return a NAN, but if your floats have sufficient precision available to
> represent 1e400, 0*1e400 might return 0.
>
> The fallback rule I use when float('nan') fails is
>
>     INF = 1e3000  # Hopefully, this should overflow to INF.
>     NAN = INF-INF  # And this hopefully will give a NaN.

The first question is "will 1eN overflow to inf?". I'm fairly sure
Python guarantees that an unrepresentable float constant will be
treated as infinity, so all you have to do is crank up the exponent
any time you suspect it'll be representable. The second is "will 0*inf
result in nan?", and I would expect that to be as reliable as INF-INF.

ChrisA

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


Thread

where in Nan defined maurog <qualsivoglia@dovetipare.nz> - 2015-01-08 14:15 +0000
  Re: where in Nan defined Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-08 07:24 -0700
    Re: where in Nan defined Marko Rauhamaa <marko@pacujo.net> - 2015-01-08 16:37 +0200
      Re: where in Nan defined Chris Angelico <rosuav@gmail.com> - 2015-01-09 01:45 +1100
        Re: where in Nan defined Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2015-01-08 16:55 +0200
      Re: where in Nan defined Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2015-01-08 16:50 +0200
        Re: where in Nan defined Chris Angelico <rosuav@gmail.com> - 2015-01-09 01:58 +1100
          Re: where in Nan defined Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-09 12:46 +1100
            Re: where in Nan defined Chris Angelico <rosuav@gmail.com> - 2015-01-09 13:07 +1100
            Re: where in Nan defined Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-08 19:12 -0700
            Re: where in Nan defined Chris Angelico <rosuav@gmail.com> - 2015-01-09 13:25 +1100
  Re: where in Nan defined Chris Angelico <rosuav@gmail.com> - 2015-01-09 01:28 +1100

csiph-web