Arithmetic error when comparing NaN

Bug #1712697 reported by Christophe on 2017-08-23
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

1. Not sure if this is intended or not, but comparing two (quiet) NaN using "=" throws floating-point-invalid-operation; I would expect the result to be NIL, based on IEEE-754.

2. (= (sb-kernel:make-single-float #x7FFFFFFF)
      (sb-kernel:make-single-float #x7FFFFFFF))

; Evaluation aborted on #<FLOATING-POINT-INVALID-OPERATION {1006900C03}>.

3. sbcl --version




I am in a Yak shaving process: I was using the IEEE-FLOATS library and noticed that SBCL defines custom floating-point operations in SB-EXT; I generated a NaN with MAKE-SINGLE-FLOAT and wanted to see what Slime's fancy inspector would do with that value. An exception occurred instead, which leads me to send a pull request (see commit

Now, I am wondering if this is really necessary: shouldn't TWO-ARG-= simply returns NIL when given at least one NaN?

description: updated
description: updated
Christophe (junke-christophe) wrote :

Ok, the current behavior is probably fine because it is better to signal the caller that we are operating on NaN values than to silently return NIL. It is also fine with IEEE-754 which defines FP exceptions.

Changed in sbcl:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers