diff --git a/src/lisp/s_expm1.c b/src/lisp/s_expm1.c index 4e9bae8174ffa2e63f816a63e96e751055741da9..64ee69accfce55d503ac414e37c873ea78ab6f61 100644 --- a/src/lisp/s_expm1.c +++ b/src/lisp/s_expm1.c @@ -160,8 +160,8 @@ Q5 = -2.01099218183624371326e-07; /* BE8AFDB7 6E09C32D */ } if(xsb!=0) { /* x < -56*ln2, return -1.0 with inexact */ - if(x+tiny<0.0) /* raise inexact */ - return tiny-one; /* return -1 */ + fdlibm_setexception(x, FDLIBM_INEXACT); + return tiny - one; } } diff --git a/tests/fdlibm.lisp b/tests/fdlibm.lisp index 16c3be43da5a545e479b90cbc08541632252dff1..5bde0cfdcd30edc1501644ba9f4bed7d64912816 100644 --- a/tests/fdlibm.lisp +++ b/tests/fdlibm.lisp @@ -163,7 +163,12 @@ (kernel:%expm1 709.8d0)) ) (kernel::with-float-traps-masked (:invalid) - (assert-true (ext::float-nan-p (kernel:%expm1 *snan*))))) + (assert-true (ext::float-nan-p (kernel:%expm1 *snan*)))) + ;; expm1(x) = -1 for x < -56*log(2), signaling inexact + (let ((x (* -57 (log 2d0)))) + (with-inexact-exception-enabled + (assert-error 'floating-point-inexact + (kernel:%expm1 x))))) (define-test %log1p.exceptions (:tag :fdlibm)