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


Groups > comp.lang.python > #7071

Re: float("nan") in set or as key

References (3 earlier) <ish1fg029vl@news1.newsguy.com> <mailman.2475.1307315609.9059.python-list@python.org> <4dec2ba6$0$29996$c3e8da3$5496439d@news.astraweb.com> <mailman.2480.1307333467.9059.python-list@python.org> <4dec5e9f$0$29988$c3e8da3$5496439d@news.astraweb.com>
Date 2011-06-06 15:10 +1000
Subject Re: float("nan") in set or as key
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.2482.1307337010.9059.python-list@python.org> (permalink)

Show all headers | View raw


On Mon, Jun 6, 2011 at 2:59 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> On Mon, 06 Jun 2011 14:11:03 +1000, Chris Angelico wrote:
>> So does this mean that:
>> (with signalling NANs) should trap on the second line but not the first?

BTW, by "should" I meant "would if Python's float were 100% IEEE-754 compliant".

> I don't think that there's any way to tell IEEE-754 for operations on
> NANs to return signalling NANs. As I understand it, the idea is:
>
>
> - if you want exceptions to signal, set the appropriate traps;
> - if you want NANs that propagate through your calculation, clear the
> traps and you'll get propagating NANs;
> - if you need to detect the presence of a NAN in your calculation, you
> can inspect the flags at any time and take whatever action you want;
> - and if you want a signalling NAN, you have to inject it yourself into
> your calculation, and then avoid using it.

That makes plausible sense, at least. Get traps or propagate NANs.

> I'm lead to believe that signalling NANs were added to satisfy politics,
> but apart from being slightly useful for marking uninitialised memory
> before use, nobody actually uses them in practice.

I'm curious as to what sort of politics led to that.

> Wanna see something cool? You can check for inexact arithmetic:
> Not surprisingly, by default that's turned off :)

Neat. That's going to be off trapping pretty much all the time, but I
can imagine circumstances where you check the status at the end.

ChrisA

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


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