bugGNU Common Lisp - Bugs: bug #47404, some comparisons with float...

 
 

bug #47404: some comparisons with float not-a-number return T

Submitter:  Robert Dodier <robert_dodier1>
Submitted:  Mon 14 Mar 2016 03:10:00 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Invalid
Privacy:  Public Assigned to:  None
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 04 Nov 2022 06:12:14 PM UTC, comment #3: 

This item has been closed incorrectly. "This is actually not a bug per IEEE.  Comparisons with nan are undefined." -- that isn't so.

According to IEEE 754, all comparisons of a float with NaN are defined, and yield false (even NaN == NaN yields false), except NaN != NaN yields true.

This is summarized in e.g.: https://en.wikipedia.org/wiki/NaN

Anonymous
Thu 11 Nov 2021 10:29:20 PM UTC, comment #2: 

Greetings, and thanks for your report!  This is actually not a bug per IEEE.  Comparisons with nan are undefined.

Camm Maguire <camm>
Group administrator
Mon 14 Mar 2016 03:13:50 AM UTC, comment #1: 

Also, I note that not-a-number is displayed as #<-nan> as if it were negative. I am guessing that NaN will be displayed correctly (without the minus sign) when the numeric comparison bug is fixed.

Robert Dodier <robert_dodier1>
Mon 14 Mar 2016 03:10:00 AM UTC, original submission:  

Numerica comparisons with float not-a-number should always return NIL. But GCL appears to consider NaN to be less than all floats, including itself.

Example with doubles shown here. Same behavior with single floats.

I'm working on Ubuntu 14.04.


$ gcl
GCL (GNU Common Lisp)  2.6.12 ANSI    Aug 12 2015 09:36:50
Source License: LGPL(gcl,gmp), GPL(unexec,bfd,xgcl)
Binary License:  GPL due to GPL'ed components: (XGCL READLINE UNEXEC)
Modifications of this banner must retain notice of a compatible license
Dedicated to the memory of W. Schelter

Use (help) to get some basic information on how to use GCL.
Temporary directory for compiler files set to /tmp/

>(defvar x 1d300)

X

>(defvar i (* x x))

I

>(defvar n (- i i))

N

>(setq si:*print-nans* t)

T

>i

#<inf>

>n

#<-nan>

>(every #'(lambda (a) (< n a)) (list n i (- i) 1 0 -1 1e7 -3d5))

T

>


Robert Dodier <robert_dodier1>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by camm (Posted a comment)
  • -email is unavailable- added by robert_dodier1 (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-11-11 camm StatusNone Invalid
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code