Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!ecngs!feeder2.ecngs.de!novso.com!newsfeed.xs4all.nl!newsfeed2.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.013 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'float': 0.07; 'overflow': 0.09; 'python': 0.11; 'jan': 0.12; 'exponent': 0.16; 'fallback': 0.16; 'inf': 0.16; 'infinity,': 0.16; 'nan': 0.16; 'subject:where': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'fairly': 0.24; 'question': 0.24; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'constant': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'fri,': 0.33; 'received:google.com': 0.35; 'should': 0.36; 'to:addr:python- list': 0.38; 'pm,': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'worry': 0.60; 'first': 0.61; '2015': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=D/lwK9rof1/I5GJwqE8Wxc9MNdWmL6eYUJCnL6fUWwM=; b=NnNqZajO1e1gARvrl9wGd02vtrwZOUmhF8l6LSuS6BhyxHRlDYMolLuae9G2cpb14C EhJNemDV/6YdUkkoQ9E++HuYOoPYaVHAMOvb2wXFuUNynve/F+hFs6HZw8R1ePtEuDsI KUCOdfR8Mx3GgLBZck0F3FoUSS6dwvVdM007dFhfx41jvPrhryl1n5+qFoPNzduI/wpZ 4gHpyIdbPBpdatpT5yfaZzaUaTX3/MBdIFSpKjU/OpgbH4nVdRDKOMTR4WjZ0Nn1TK2+ d0agbvzqCv158d+xrj2vzj3f3Mh1k85NHZHMzK/ULlWh4cx/HyZGVry48POhd41/zbO3 c1Iw== X-Received: by 10.66.97.6 with SMTP id dw6mr19616127pab.114.1420769605828; Thu, 08 Jan 2015 18:13:25 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <87zj9te3tz.fsf@elektro.pacujo.net> <54af32f4$0$12990$c3e8da3$5496439d@news.astraweb.com> From: Ian Kelly Date: Thu, 8 Jan 2015 19:12:45 -0700 Subject: Re: where in Nan defined To: Python 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1420769609 news.xs4all.nl 2898 [2001:888:2000:d::a6]:57747 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:83389 On Thu, Jan 8, 2015 at 7:07 PM, Chris Angelico wrote: > On Fri, Jan 9, 2015 at 12:46 PM, Steven D'Aprano >> 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. Or to never have to worry about it: INF = 1e400 while not math.isinf(INF): INF *= INF