diff --git a/src/code/irrat-dd.lisp b/src/code/irrat-dd.lisp index 29627b551e5c0f36680174383fbd2dc24a5ae026..438339fa849b7cc97733818a7ad77964fc6d2b77 100644 --- a/src/code/irrat-dd.lisp +++ b/src/code/irrat-dd.lisp @@ -368,10 +368,17 @@ (optimize (speed 3) (space 0) (inhibit-warnings 3))) ;; Separate mantissa from exponent - (multiple-value-bind (x e) + (multiple-value-bind (x e sign) (decode-float x) (declare (type double-double-float x) (type double-float-exponent e)) + (when (zerop x) + ;; Handle log(+/-0). Return -inf or -inf + i*pi, but signal a + ;; division by zero. + (return-from dd-%log + (if (minusp sign) + (complex (/ (- x)) dd-pi) + (/ (- x))))) (let ((z 0w0) (y 0w0)) (declare (type double-double-float z y)) diff --git a/tests/trac.lisp b/tests/trac.lisp index f8b425826b085edb78b6b0cbb596ab97c098cae3..9a02189f97d3988956c50325c8915ccd970c2340 100644 --- a/tests/trac.lisp +++ b/tests/trac.lisp @@ -342,7 +342,10 @@ (ext:with-float-traps-masked (:divide-by-zero) (log -0d0))) (assert-equal (complex ext:single-float-negative-infinity (float pi 1f0)) - (ext:with-float-traps-masked (:divide-by-zero) (log -0f0))))) + (ext:with-float-traps-masked (:divide-by-zero) (log -0f0))) + (assert-equal + (complex ext:double-double-float-negative-infinity kernel:dd-pi) + (ext:with-float-traps-masked (:divide-by-zero) (log -0w0))))) (define-test trac.93 (:tag :trac)