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


Groups > comp.lang.python > #74258

Re: NaN comparisons - Call For Anecdotes

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4a.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.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'algorithm': 0.04; '64-bit': 0.07; 'float': 0.07; 'anders': 0.09; 'converted': 0.09; 'input,': 0.09; 'things,': 0.09; 'cc:addr:python-list': 0.11; 'accepting': 0.14; '1:08': 0.16; 'bitwise': 0.16; 'comparisons,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'integer.': 0.16; 'nans': 0.16; 'retrieving': 0.16; 'storing': 0.16; 'tuples,': 0.16; 'unpack': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'later': 0.20; 'seems': 0.21; 'example': 0.22; 'cc:addr:python.org': 0.22; 'string,': 0.24; 'earlier': 0.24; 'cc:2**0': 0.24; 'compare': 0.26; 'handling': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'point': 0.28; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "d'aprano": 0.31; 'gather': 0.31; 'steven': 0.31; 'them?': 0.31; 'trivial': 0.31; 'values.': 0.31; 'text': 0.33; 'becomes': 0.33; 'not.': 0.33; 'form.': 0.35; 'usual': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'doing': 0.36; 'easiest': 0.38; 'list,': 0.38; 'does': 0.39; 'how': 0.40; 'algorithms': 0.60; 'simple': 0.61; 'back': 0.62; 'such': 0.63; 'stand': 0.64; 'reply': 0.66; 'capable': 0.67; 'jul': 0.74; 'special': 0.74; 'subject:For': 0.78; 'calculations': 0.84; 'device,': 0.91; 'to:none': 0.92; 'imagine': 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=lodIF48LMFVe+BhqZZfZWPbJfwei8VZxDJWpJsyQGqg=; b=wnXTPOnDzQKEVbSS3Kch0J+4Q4v+/IMiuG/aZStCN2HvN2qXBrb9cVJX82A4OMG0Xk ojUPqOJkgSSLHkbw2lUi+QE7sUK2Cbz4vPpekzlyugM/UjYsOmd9TiD+meMih0fBLTyv 2sCCTf5fGYbzg1EVnh3GntKjq22k3XA4IeJKJvSQpBpIWulK/SK5UvI9eoeLtDkDqdog WPy2VQs1HMuCBSMJV1+WQKAe5OD0sQ+s1GevO2fbe0iXpDZyfenj9TGnYqiUHkxoKyrj 9iEMuzf/0Iv8uLkeyblZ8i5fMGD9pv7U/I3sDkQu9AhvWVB30KwqIium2XJrixLk41f3 89Wg==
MIME-Version 1.0
X-Received by 10.52.119.179 with SMTP id kv19mr33653846vdb.3.1404918806601; Wed, 09 Jul 2014 08:13:26 -0700 (PDT)
In-Reply-To <53BD5ADF.2050409@jmunch.dk>
References <mailman.11626.1404831235.18130.python-list@python.org> <53bc26ca$0$29995$c3e8da3$5496439d@news.astraweb.com> <mailman.11653.1404846131.18130.python-list@python.org> <53bc8861$0$29995$c3e8da3$5496439d@news.astraweb.com> <53BD5ADF.2050409@jmunch.dk>
Date Thu, 10 Jul 2014 01:13:26 +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.11693.1404918816.18130.python-list@python.org> (permalink)
Lines 37
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1404918816 news.xs4all.nl 2950 [2001:888:2000:d::a6]:42858
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:74258

Show key headers only | View raw


On Thu, Jul 10, 2014 at 1:08 AM, Anders J. Munch <2014@jmunch.dk> wrote:
> Steven D'Aprano wrote:
>>
>> It seems to me that the trivial work-around is:
>>
>> * gather packed floats from some device, as ints
>> * process them *as ints* in some way which requires reflexivity
>> * unpack back into floats
>> * (maybe) much later perform numeric calculations on them
>>
>>
>> Although perhaps I don't understand your use-case.
>
>
> Clearly you do not. floats are not ints. I have no idea how you imagine
> processing IEEE-754 floating-point values in int form.
>
> My use case is: Working with IEEE-754 floating-point values. That means
> storing and retrieving them, serialising and transferring them, accepting
> them as user input, printing them, all the usual things you do with values.
>
> And doing so in a way that does not require special handling in algorithms
> that are otherwise generic.
> When the same algorithm is capable of dealing with ints, bytestrings, text
> string, tuples, list, dictionaries, time stamps, NoneType's, bools,
> floating-point floats and a thousand other things, then NaNs stand out as
> the values that have special algorithm-breaking magic.
>
> I gave an example of such an algorithm in an earlier reply to Chris.

If you need to do bitwise comparisons, then the easiest way is to use
the bitpattern, converted to an integer. A 64-bit float becomes a
64-bit integer. It's then very simple to compare them, and reflexivity
is maintained. At what point do you actually need them to be floats?
What are you really doing with them?

ChrisA

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


Thread

NaN comparisons - Call For Anecdotes "Anders J. Munch" <2014@jmunch.dk> - 2014-07-08 16:53 +0200
  Re: NaN comparisons - Call For Anecdotes Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-07-08 17:13 +0000
    Re: NaN comparisons - Call For Anecdotes Chris Angelico <rosuav@gmail.com> - 2014-07-09 03:21 +1000
    Re: NaN comparisons - Call For Anecdotes "Anders J. Munch" <2014@jmunch.dk> - 2014-07-08 21:02 +0200
      Re: NaN comparisons - Call For Anecdotes Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-07-09 00:10 +0000
        Re: NaN comparisons - Call For Anecdotes Terry Reedy <tjreedy@udel.edu> - 2014-07-09 00:57 -0400
          Re: NaN comparisons - Call For Anecdotes Steven D'Aprano <steve@pearwood.info> - 2014-07-09 06:43 +0000
            Re: NaN comparisons - Call For Anecdotes Chris Angelico <rosuav@gmail.com> - 2014-07-09 16:52 +1000
        Re: NaN comparisons - Call For Anecdotes "Anders J. Munch" <2014@jmunch.dk> - 2014-07-09 17:08 +0200
          Re: NaN comparisons - Call For Anecdotes Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-07-09 16:53 +0000
            Re: NaN comparisons - Call For Anecdotes Ian Kelly <ian.g.kelly@gmail.com> - 2014-07-09 11:26 -0600
            Re: NaN comparisons - Call For Anecdotes "Anders J. Munch" <2014@jmunch.dk> - 2014-07-09 19:44 +0200
        Re: NaN comparisons - Call For Anecdotes Chris Angelico <rosuav@gmail.com> - 2014-07-10 01:13 +1000
        Re: NaN comparisons - Call For Anecdotes "Anders J. Munch" <2014@jmunch.dk> - 2014-07-09 18:24 +0200
    Re: NaN comparisons - Call For Anecdotes "Anders J. Munch" <2014@jmunch.dk> - 2014-07-08 21:25 +0200
  Re: NaN comparisons - Call For Anecdotes Rustom Mody <rustompmody@gmail.com> - 2014-07-09 20:07 -0700

csiph-web