FTRUNCATE return the wrong zero with a certain THE argument

Bug #1732009 reported by Paul F. Dietz
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
Medium
Unassigned

Bug Description

(defun f17a (x)
  (ftruncate 0 x))

(defun f17b (x)
  (ftruncate 0 (the (member 1.0d0 -10.0d0) x)))

(defun f17c (x)
  (ftruncate 0 (the double-float x)))

(defun f17d (x)
  (declare (type (member 1.0d -10.0d0) x))
  (ftruncate 0 x))

(f17a -10.0d0) ==> -0.0d0, 0.0d0
(f17b -10.0d0) ==> 0.0d0, 0.0d0 ;; not the same as the others
(f17c -10.0d0) ==> -0.0d0, 0.0d0
(f17d -10.0d0) ==> -0.0d0, 0.0d0

Revision history for this message
Paul F. Dietz (paul-f-dietz) wrote :

It may be this is not actually a bug, since (= 0.0 -0.0) is true. Floating point operations can return slightly different values when inlined anyway.

Stas Boukarev (stassats)
Changed in sbcl:
status: New → Triaged
importance: Undecided → Medium
assignee: nobody → Stas Boukarev (stassats)
Stas Boukarev (stassats)
Changed in sbcl:
assignee: Stas Boukarev (stassats) → nobody
Revision history for this message
Paul F. Dietz (paul-f-dietz) wrote :

Another example:

(ffloor 0 1.0) ==> 0.0, 0.0
(ffloor 0 -1.0) ==> -0.0, 0.0

But calling

(compile nil '(lambda (x) (ffloor 0 (the (member -1.0 1.0) x))))

on 1.0 and -1.0 returns 0.0, 0.0 in both cases.

Revision history for this message
Stas Boukarev (stassats) wrote :

Looks like 27b1003e738809a3628bea6eef074a81467fa3c2 has fixed this.

Changed in sbcl:
status: Triaged → Fix Committed
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.