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


Groups > comp.lang.python > #6501

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

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <marduk@letterboxes.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.016
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'mrab': 0.05; '+0100,': 0.07; '>>>': 0.12; 'wrote:': 0.14; 'nan': 0.16; 'spec,': 0.16; 'subject:key': 0.16; 'subject:set': 0.16; 'received:internal': 0.19; 'header:In-Reply-To:1': 0.21; 'received:10.202': 0.23; 'received:10.202.2': 0.23; 'received:66.111': 0.23; 'received:66.111.4': 0.23; 'received:messagingengine.com': 0.23; 'received:smtp.messagingengine.com': 0.23; 'sun,': 0.30; 'equal': 0.31; "can't": 0.32; 'to:addr:python-list': 0.33; 'things': 0.33; 'skip:{ 10': 0.35; '(to': 0.37; 'two': 0.37; 'but': 0.38; 'subject:: ': 0.38; 'received:192': 0.38; 'sometimes': 0.39; 'itself.': 0.39; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'manner': 0.62; 'message- id:@localhost.localdomain': 0.78; '00:41': 0.84
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d=messagingengine.com; h=subject:from:to:date:in-reply-to:references:content-type:content-transfer-encoding:message-id:mime-version; s=smtpout; bh=3O590Co3WCZlaZm2tmN0XXZkRTw=; b=V5B+o4W31hsM+e1+cFU5Z1JhMy5RYB39g181OeVCytIydc6X2ydDlf3DjR20ppt+tplc/1MszjnYm3idyRmcTseoJ5t+ENiBclbLy005+9wZ7GLZogL9roUpUHF+eiZRG+sO9zvmBcTDwcJRGBRXwGZgWamgjNdZwrSKfE8YCQo=
X-Sasl-enc eSSrFgzkUfPZ9JikhzIwIWzBmvDzRMczz+DFTr4S3OTN 1306628926
Subject Re: float("nan") in set or as key
From Albert Hopkins <marduk@letterboxes.org>
To python-list@python.org
Date Sat, 28 May 2011 20:28:46 -0400
In-Reply-To <4DE1881C.8000701@mrabarnett.plus.com>
References <4DE1881C.8000701@mrabarnett.plus.com>
Face iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAAXNSR0IArs4c6QAAADBQTFRF1///CwsLGxsbJycnNzc3RUVFU1NTYmJicXFxf39/jIyMm5ubq6urubm5yMjI3t7eukg4JQAAAAF0Uk5TAEDm2GYAAAIoSURBVDhPpZC9btRQEEbPGIJQhOIZB4SEhGJ7W/42lihoKCJ6agoeglfgDXiQPAGEio5sKGgTLxRIFNk7DigV7FD4J4SW23jud+75ZA38x9ncnb3wf0PgjZnZdvo35rVZZWa3RiLDd+PGMNz5oABkw/2e9ne+HTgwGRt3nejHzc8Gk/EURfvx/IgLcK3YNZWB7C8vwFqtqcxEAPYD4CoAr5xUiBaJlfOrvTA+IRLqLhisWx/B9RItzckjHCJNxtqKGhRBgEiTAWCIBqGXDNBODEdBIWIEgquCiosD6GQsTYzAVVUAH0FCFDPP3ce8Byenx0hhFRBoX5cBFPXJUVILUog6rTOs5Mv5DnGyOAaXHMvb0fiU3z8QbNZAjmg5VXVbP/N0uHhyWJrAl8RYhebzVcq+K4CJ2WgomSbWsSsguRY6GtncD0N0EYImEcrRkPUxXcrKflNYN4LUmqKndQVOV5qOIDp5Vhb518oEqqxgBFuyOhSKlRF4NptPhp22Ee0ylnioNfVkPPLSix1SG9BJrRN4aFcevfNIKw8f8h5k8vtsnlUauSBiF2DD6/ePd5LPAOvzHpw97F6+dbHOk1T1X4DnXN2rlF+OWKXAuN3Cj3HHNW5u/13FzeQtEkv/YU0vDCATjZSn8KqZXwLdA3Kny+q6GZoGwPPFmZ5oNWt29TK4/XSVpK6bPRny4a+Qx1+FrNkrdATji/XHhdTbw55gMrC0TaFTEfwB/cbNxoZIacsAAAAASUVORK5CYII=
Content-Type text/plain; charset="UTF-8"
X-Mailer Evolution 3.0.1
Content-Transfer-Encoding 7bit
Mime-Version 1.0
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.2207.1306628936.9059.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 82.94.164.166
X-Trace 1306628936 news.xs4all.nl 49179 [::ffff:82.94.164.166]:36865
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:6501

Show key headers only | View raw


On Sun, 2011-05-29 at 00:41 +0100, MRAB wrote:
> Here's a curiosity. float("nan") can occur multiple times in a set or as 
> a key in a dict:
> 
>  >>> {float("nan"), float("nan")}
> {nan, nan}
> 
These two nans are not equal (they are two different nans)

> except that sometimes it can't:
> 
>  >>> nan = float("nan")
>  >>> {nan, nan}
> {nan}

This is the same nan, so it is equal to itself.

Two "nan"s are not equal in the manner that 1.0 and 1.0 are equal:

>>> 1.0 == 1.0
True
>>> float("nan") == float("nan")
False


I can't cite this in a spec, but it makes sense (to me) that two things
which are nan are not necessarily the same nan.

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


Thread

Re: float("nan") in set or as key Albert Hopkins <marduk@letterboxes.org> - 2011-05-28 20:28 -0400
  Re: float("nan") in set or as key Erik Max Francis <max@alcyone.com> - 2011-05-28 17:44 -0700
  Re: float("nan") in set or as key Grant Edwards <invalid@invalid.invalid> - 2011-05-29 02:25 +0000
    Re: float("nan") in set or as key Wolfgang Rohdewald <wolfgang@rohdewald.de> - 2011-05-29 10:27 +0200
      Re: float("nan") in set or as key Grant Edwards <invalid@invalid.invalid> - 2011-05-29 14:41 +0000
        Re: float("nan") in set or as key MRAB <python@mrabarnett.plus.com> - 2011-05-29 18:44 +0100
          Re: float("nan") in set or as key Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-29 18:27 +0000
        Re: float("nan") in set or as key Chris Angelico <rosuav@gmail.com> - 2011-05-30 03:50 +1000
        Re: float("nan") in set or as key Christian Heimes <lists@cheimes.de> - 2011-05-29 20:05 +0200
          Re: float("nan") in set or as key Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-29 18:46 +0000
        Re: float("nan") in set or as key Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-05-29 20:36 -0700

csiph-web