From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: James Clark Newsgroups: gmane.emacs.bugs Subject: NaN and equal Date: Wed, 13 Aug 2003 08:24:10 +0700 Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Message-ID: <3F39933A.9090807@jclark.com> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1060738222 5188 80.91.224.253 (13 Aug 2003 01:30:22 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 13 Aug 2003 01:30:22 +0000 (UTC) Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Aug 13 03:30:20 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19mkSy-0003Qw-00 for ; Wed, 13 Aug 2003 03:30:20 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19mkQa-0007Lo-OU for geb-bug-gnu-emacs@m.gmane.org; Tue, 12 Aug 2003 21:27:52 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.20) id 19mkQV-0007LI-Ez for bug-gnu-emacs@gnu.org; Tue, 12 Aug 2003 21:27:47 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) id 19mkPz-0007FA-Ni for bug-gnu-emacs@gnu.org; Tue, 12 Aug 2003 21:27:46 -0400 Original-Received: from [203.130.150.186] (helo=server.bkk.thaiopensource.com) by monty-python.gnu.org with esmtp (Exim 4.20) id 19mkPv-0007Du-EE for bug-gnu-emacs@gnu.org; Tue, 12 Aug 2003 21:27:13 -0400 Original-Received: from jclark.com ([203.130.150.187]) by server.bkk.thaiopensource.com (8.11.6/8.11.6) with ESMTP id h7D1QrY30616 for ; Wed, 13 Aug 2003 08:26:54 +0700 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030225 X-Accept-Language: en-us, en Original-To: bug-gnu-emacs@gnu.org X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Bug reports for GNU Emacs, the Swiss army knife of text editors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.bugs:5536 X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:5536 With Emacs 21.3.1, i686-pc-linux-gnu (equal 0.0e+NaN 0.0e+NaN) returns nil. This does not seem consistent with the documentation of equal. I would suggest that (= 0.0e+NaN 0.0e+NaN) continues to return nil, for consistency with the IEEE floating point standard (which of course says that NaN != NaN), but that (equal 0.0e+NaN 0.0e+NaN) return t, so that hash-tables and alists with NaN can work. Here's a patch. I don't think this should cause any problems on systems without NaN. *** /home/jjc/var/build/emacs-21.3/src/fns.c~ 2002-12-04 19:38:32.000000000 +0700 --- /home/jjc/var/build/emacs-21.3/src/fns.c 2003-08-12 23:04:52.000000000 +0700 *************** *** 1976,1982 **** switch (XTYPE (o1)) { case Lisp_Float: ! return (extract_float (o1) == extract_float (o2)); case Lisp_Cons: if (!internal_equal (XCAR (o1), XCAR (o2), depth + 1)) --- 1976,1990 ---- switch (XTYPE (o1)) { case Lisp_Float: ! { ! double d1, d2; ! ! d1 = extract_float (o1); ! d2 = extract_float (o2); ! /* If d is NaN, then d != d. Two NaNs should be equal ! even though they are not =. */ ! return d1 == d2 || (d1 != d1 && d2 != d2); ! } case Lisp_Cons: if (!internal_equal (XCAR (o1), XCAR (o2), depth + 1)) James