Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #7023
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python.': 0.04; 'handler': 0.05; 'high-level': 0.05; 'python?': 0.05; 'raises': 0.07; 'python': 0.08; '>>>>': 0.09; 'context.': 0.09; 'default)': 0.09; 'exceptions': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'underlying': 0.09; 'pm,': 0.10; '>>>': 0.12; 'exception': 0.12; 'wrote:': 0.14; 'arithmetic,': 0.16; 'disables': 0.16; 'enigma': 0.16; 'furman': 0.16; 'kern': 0.16; 'low-level': 0.16; 'nan': 0.16; 'nans,': 0.16; 'subject:key': 0.16; 'subject:set': 0.16; 'translates': 0.16; 'trap': 0.16; 'zero"': 0.16; 'language': 0.18; 'errors,': 0.19; 'header:In-Reply-To:1': 0.21; 'right.': 0.22; 'module,': 0.23; 'optional': 0.23; 'fri,': 0.23; 'creating': 0.24; "doesn't": 0.25; '(and': 0.25; 'example': 0.27; 'explicitly': 0.29; 'interpret': 0.29; 'module': 0.30; 'decimal': 0.30; 'disabled': 0.30; 'signals': 0.30; 'about.': 0.32; 'steven': 0.32; 'header:X-Complaints-To:1': 0.32; 'does': 0.33; 'to:addr:python- list': 0.33; 'asking': 0.33; 'however,': 0.34; 'there': 0.35; 'header:User-Agent:1': 0.35; '-0700,': 0.35; "d'aprano": 0.35; 'thus,': 0.35; 'received:24': 0.35; 'received:rr.com': 0.36; 'issue': 0.37; 'think': 0.38; 'received:org': 0.38; 'but': 0.38; 'though': 0.38; 'signal': 0.38; 'subject:: ': 0.38; 'user': 0.39; 'should': 0.39; 'attempt': 0.39; 'header:Mime-Version:1': 0.39; 'either': 0.39; 'to:addr:python.org': 0.39; 'really': 0.40; 'generate': 0.60; 'providing': 0.61; 'world': 0.63; 'our': 0.63; 'details': 0.64; 'believe': 0.66; 'states': 0.67; 'issued': 0.73; 'mandates': 0.84; 'mechanism.': 0.84; 'namely': 0.84; '0.0': 0.91; 'eco': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Robert Kern <robert.kern@gmail.com> |
| Subject | Re: float("nan") in set or as key |
| Date | Sat, 04 Jun 2011 16:49:40 -0500 |
| Organization | The Church of Last Thursday |
| References | <7d1ad033-b412-4ccb-8e7f-d5ef151e6804@glegroupsg2000goo.googlegroups.com> <4de9ba8b$0$29996$c3e8da3$5496439d@news.astraweb.com> <mailman.2451.1307167545.9059.python-list@python.org> <4de9fc6b$0$29996$c3e8da3$5496439d@news.astraweb.com> <4DEAA378.80309@stoneleaf.us> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | rrcs-24-227-244-203.sw.biz.rr.com |
| User-Agent | Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 |
| In-Reply-To | <4DEAA378.80309@stoneleaf.us> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2460.1307224196.9059.python-list@python.org> (permalink) |
| Lines | 44 |
| NNTP-Posting-Host | 82.94.164.166 |
| X-Trace | 1307224197 news.xs4all.nl 49183 [::ffff:82.94.164.166]:53225 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:7023 |
Show key headers only | View raw
On 6/4/11 4:28 PM, Ethan Furman wrote: > Steven D'Aprano wrote: >> On Fri, 03 Jun 2011 23:04:38 -0700, Ethan Furman wrote: >> >>> Steven D'Aprano wrote: >>>> NANs are not necessarily errors, they're hardly silent, and if you >>>> don't want NANs, the standard mandates that there be a way to turn them >>>> off. >>> So how does one turn them off in standard Python? >> >> Turn them off? You have to find a way to turn them on first! What makes you >> think that Python supports IEEE-754 for floats? > > So if Python doesn't support IEEE-754 for floats, why the big deal about NaNs? Steven is being a little hyperbolic. Python does not fully conform to all of the details of the IEEE-754 specification, though it does conform to most of them. In particular, it raises an exception when you divide by 0.0 when the IEEE-754 specification states that you ought to issue the "divide by zero" or "invalid" signal depending on the numerator (and which may be trapped by the user, but not by default) and will return either an inf or a NaN value if not trapped. Thus, the canonical example of a NaN-returning operation in fully-conforming IEEE-754 arithmetic, 0.0/0.0, raises an exception in Python. You can generate a NaN by other means, namely dividing inf/inf. One other deviation is the one which you were asking about. The standard does say that the "invalid" signal should be issued in most circumstances that generate a NaN and that the user should be able to trap that signal. Python explicitly disables that mechanism. It used to provide an optional module, fpectl, for providing a signal handler for those. However, creating a handler for such a low-level signal in a high-level language like Python is inherently unsafe, so it is not really supported any more. The decimal module mostly gets it right. It translates the signals into Python exceptions that can be disabled in a particular context. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: float("nan") in set or as key Carl Banks <pavlovevidence@gmail.com> - 2011-06-03 13:27 -0700
Re: float("nan") in set or as key Chris Angelico <rosuav@gmail.com> - 2011-06-04 06:35 +1000
Re: float("nan") in set or as key Chris Torek <nospam@torek.net> - 2011-06-05 22:54 +0000
Re: float("nan") in set or as key Chris Angelico <rosuav@gmail.com> - 2011-06-06 09:13 +1000
Re: float("nan") in set or as key Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-06 01:21 +0000
Re: float("nan") in set or as key Chris Torek <nospam@torek.net> - 2011-06-06 01:56 +0000
Re: float("nan") in set or as key Chris Angelico <rosuav@gmail.com> - 2011-06-06 14:11 +1000
Re: float("nan") in set or as key Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-06 04:59 +0000
Re: float("nan") in set or as key Chris Angelico <rosuav@gmail.com> - 2011-06-06 15:10 +1000
Re: float("nan") in set or as key Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-04 04:54 +0000
Re: float("nan") in set or as key Ethan Furman <ethan@stoneleaf.us> - 2011-06-03 23:04 -0700
Re: float("nan") in set or as key Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-04 09:35 +0000
Re: float("nan") in set or as key Ben Finney <ben+python@benfinney.id.au> - 2011-06-04 20:20 +1000
Re: float("nan") in set or as key Ethan Furman <ethan@stoneleaf.us> - 2011-06-04 14:28 -0700
Re: float("nan") in set or as key Robert Kern <robert.kern@gmail.com> - 2011-06-04 16:49 -0500
Re: float("nan") in set or as key Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-05 02:03 +0000
Re: float("nan") in set or as key Robert Kern <robert.kern@gmail.com> - 2011-06-05 14:44 -0500
csiph-web