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


Groups > comp.lang.python > #74771

Re: NaN comparisons - Call For Anecdotes

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!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.075
X-Spam-Evidence '*H*': 0.85; '*S*': 0.00; '(at': 0.04; 'subsequent': 0.05; 'abuse': 0.07; 'meaningful': 0.09; 'thrown': 0.09; 'cc:addr :python-list': 0.11; '"here': 0.16; '754': 0.16; 'defer': 0.16; 'finite': 0.16; 'finite,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'nan': 0.16; 'nans': 0.16; 'ought': 0.16; 'simplest': 0.16; 'sat,': 0.16; 'appropriate': 0.16; 'wrote:': 0.18; 'obviously': 0.18; 'bit': 0.19; 'cc:addr:python.org': 0.22; 'instance,': 0.24; 'logical': 0.24; '(or': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; '(like': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'calculated': 0.31; "d'aprano": 0.31; 'depth': 0.31; 'object.': 0.31; 'quantities': 0.31; 'steven': 0.31; 'probably': 0.32; 'handled': 0.32; '(e.g.': 0.33; 'third': 0.33; '"the': 0.34; 'sense': 0.34; 'there,': 0.34; 'maybe': 0.34; "can't": 0.35; 'something': 0.35; 'case,': 0.35; 'definition': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'limitations': 0.36; 'mass': 0.36; 'possible': 0.36; 'should': 0.36; 'two': 0.37; 'system,': 0.38; 'e.g.': 0.38; 'anything': 0.39; 'does': 0.39; 'sure': 0.39; 'either': 0.39; 'read': 0.60; 'truly': 0.60; 'tell': 0.60; 'took': 0.61; "you're": 0.61; 'first': 0.61; 'real': 0.63; 'such': 0.63; 'card': 0.63; 'our': 0.64; 'worth': 0.66; 'due': 0.66; 'between': 0.67; 'design.': 0.68; 'duty': 0.68; 'invalid': 0.68; 'jul': 0.74; 'postal': 0.74; 'subject.': 0.74; 'paper': 0.75; 'subject:For': 0.78; 'low': 0.83; 'calculations': 0.84; 'fourth': 0.84; 'reading,': 0.84; 'valid,': 0.84; 'to:none': 0.92; 'average': 0.93; 'sheet': 0.93
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=WNxIh3jLzikPx2KpfnocP2pxrIsB+fN6u/yp0ZRPadk=; b=u1z/HojnysdZnSIVG93VWM0OdZrhNNZdxgMy1nRK+iPhIJiTxPAQXfSR5ODU+V/mF3 93TSGdDbn6gccIz5QzkN3+eeMJb1T2HGy3E0k85bjKcJlfvmYaMBAg+9DIEyTfA05VvJ y0572xFRcy4ODQw+O5PNZDxTkRl8mWZ3lRA5QGXXUgZb/nv+cmwtveumAyXY05R4NpaH 4gwF4neF8WVFiXAKlgLkB46ChclykD3QXTwYYGLoBvmdfeAjsUAbzvBzZNsgvOFfCQ/d fO8eLH7b0I4prJyW5lQnZ1ILbqaRN+yyO7T7bIDE44dm06aCTHVuYPeJ5coYcn1e0oOd 4STQ==
MIME-Version 1.0
X-Received by 10.220.164.198 with SMTP id f6mr9074050vcy.51.1405712940439; Fri, 18 Jul 2014 12:49:00 -0700 (PDT)
In-Reply-To <53c95fef$0$9505$c3e8da3$5496439d@news.astraweb.com>
References <53BC05FB.4050707@jmunch.dk> <53BD70F4.4000504@stoneleaf.us> <53BDAF90.8010709@jmunch.dk> <CAPM-O+yiioLm-UiV2fYqc2n9qZrN+_v6RkeqJ7mOQ3Kq+cH0CQ@mail.gmail.com> <mailman.11716.1404946997.18130.python-list@python.org> <osx38e010kj.fsf@gmail.com> <mailman.11929.1405611387.18130.python-list@python.org> <53c95fef$0$9505$c3e8da3$5496439d@news.astraweb.com>
Date Sat, 19 Jul 2014 05:49:00 +1000
Subject Re: NaN comparisons - Call For Anecdotes
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.12014.1405712948.18130.python-list@python.org> (permalink)
Lines 50
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1405712948 news.xs4all.nl 2840 [2001:888:2000:d::a6]:38286
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:74771

Show key headers only | View raw


On Sat, Jul 19, 2014 at 3:57 AM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> Hmmm, there's something to what you say there, but IEEE-754 NANs seem to
> have been designed to do quadruple (at least!) duty with multiple
> meanings, including:
>
> - Missing values ("I took a reading, but I can't read my handwriting").
>
> - Data known only qualitatively, not quantitatively (e.g. windspeed =
>   "fearsome").
>
> - Inapplicable values, e.g. the average depth of the oceans on Mars.
>
> - The result of calculations which are mathematically indeterminate,
>   such as 0/0.
>
> - The result of real-valued calculations which are invalid due to
>   domain errors, such as sqrt(-1) or acos(2.5).
>
> - The result of calculations which are conceptually valid, but are
>   unknown due to limitations of floats, e.g. you have two finite
>   quantities which have both overflowed to INF, the difference
>   between them ought to be finite, but there's no way to tell what
>   it should be.

Huh, okay. I thought the definition of NaN was based on the fourth one
(mathematically indeterminate) and then it logically accepted the
subsequent two (sqrt(-1) IMO is better handled by either a complex
number or a thrown error, but NaN does make some sense there;
definitely inf-inf => nan is as logical as 0/0 => nan). The first two
seem to be better handled by SQL's NULL value (or non-value, or
something, or maybe not something); the third is a bit trickier.
Although "the average of no values" is logically calculated as 0/0
(ergo NaN makes sense there), I would say NaN isn't really right for a
truly inapplicable value - for instance, recording the mass of a
non-physical object. In an inventory system, it's probably simplest to
use 0.0 to mean "non-physical item", but it might be worth
distinguishing between "physical item with sufficiently low mass that
it underflows our measurements" (like a single sheet of paper when
you're working with postal scales) and "non-physical item with no
meaningful mass" (like credit card fees). In that case, I'm not sure
that NaN is really appropriate to the situation, but would defer to
IEE 754 on the subject.

Obviously it's possible to abuse anything to mean anything (I do
remember using nullable fields in DB2 to mean everything from "inherit
this value from parent" to "here be magic, code will work out the real
value on the fly"), but this is a question of intent and good design.

ChrisA

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


Thread

Re: NaN comparisons - Call For Anecdotes "Anders J. Munch" <2014@jmunch.dk> - 2014-07-10 01:03 +0200
  Re: NaN comparisons - Call For Anecdotes Johann Hibschman <jhibschman@gmail.com> - 2014-07-17 11:12 -0400
    Re: NaN comparisons - Call For Anecdotes Chris Angelico <rosuav@gmail.com> - 2014-07-18 01:36 +1000
      Re: NaN comparisons - Call For Anecdotes Johann Hibschman <jhibschman@gmail.com> - 2014-07-17 14:49 -0400
        Re: NaN comparisons - Call For Anecdotes Chris Angelico <rosuav@gmail.com> - 2014-07-18 04:55 +1000
          Re: NaN comparisons - Call For Anecdotes Marko Rauhamaa <marko@pacujo.net> - 2014-07-17 22:10 +0300
            Re: NaN comparisons - Call For Anecdotes Ian Kelly <ian.g.kelly@gmail.com> - 2014-07-17 14:39 -0600
              Re: NaN comparisons - Call For Anecdotes Marko Rauhamaa <marko@pacujo.net> - 2014-07-18 00:08 +0300
                Re: NaN comparisons - Call For Anecdotes Ian Kelly <ian.g.kelly@gmail.com> - 2014-07-17 17:00 -0600
                Re: NaN comparisons - Call For Anecdotes Ian Kelly <ian.g.kelly@gmail.com> - 2014-07-17 17:07 -0600
        Re: NaN comparisons - Call For Anecdotes Chris Angelico <rosuav@gmail.com> - 2014-07-18 04:59 +1000
      Re: NaN comparisons - Call For Anecdotes Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-07-18 17:57 +0000
        Re: NaN comparisons - Call For Anecdotes Chris Angelico <rosuav@gmail.com> - 2014-07-19 05:49 +1000

csiph-web