Skip to content
Snippets Groups Projects
Commit b00288b7 authored by rtoy's avatar rtoy
Browse files

sxhash is supposed to return the same value for -0.0 and +0.0 since

they are arithmetically equal.  Do this by adding 0.0 to the number,
which does nothing to the number, except convert -0.0 to 0.0.
parent 82c9ad99
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain. ;;; Carnegie Mellon University, and has been placed in the public domain.
;;; ;;;
(ext:file-comment (ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/hash-new.lisp,v 1.31 2004/05/17 18:05:33 rtoy Exp $") "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/hash-new.lisp,v 1.32 2004/06/09 14:50:05 rtoy Exp $")
;;; ;;;
;;; ********************************************************************** ;;; **********************************************************************
;;; ;;;
...@@ -935,12 +935,17 @@ ...@@ -935,12 +935,17 @@
(etypecase s-expr (etypecase s-expr
(integer (ldb sxhash-bits-byte s-expr)) (integer (ldb sxhash-bits-byte s-expr))
(single-float (single-float
(let ((bits (single-float-bits s-expr))) ;; CLHS says sxhash must return the same thing for +0.0 and
;; -0.0. We get the desired result by adding +0.0, which
;; converts -0.0 to 0.0.
(let* ((x (+ s-expr 0f0))
(bits (single-float-bits x)))
(ldb sxhash-bits-byte (ldb sxhash-bits-byte
(logxor (ash bits (- sxmash-rotate-bits)) bits)))) (logxor (ash bits (- sxmash-rotate-bits)) bits))))
(double-float (double-float
(let ((lo (double-float-low-bits s-expr)) (let* ((x (+ s-expr 0d0))
(hi (double-float-high-bits s-expr))) (lo (double-float-low-bits x))
(hi (double-float-high-bits x)))
(ldb sxhash-bits-byte (ldb sxhash-bits-byte
(logxor (ash lo (- sxmash-rotate-bits)) lo (logxor (ash lo (- sxmash-rotate-bits)) lo
(ldb sxhash-bits-byte (ldb sxhash-bits-byte
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment