diff --git a/src/lisp/e_exp.c b/src/lisp/e_exp.c index 034c59050bfd852cb5eb91ee217126dc1c36dda4..93b638e669c58a94f447c231088544c9b9cc6e34 100644 --- a/src/lisp/e_exp.c +++ b/src/lisp/e_exp.c @@ -142,7 +142,10 @@ P5 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */ return fdlibm_setexception(x, FDLIBM_OVERFLOW); } - if(x < u_threshold) return x; /* underflow */ + if(x < u_threshold) { + /* underflow */ + return fdlibm_setexception(0.0, FDLIBM_UNDERFLOW); + } } /* argument reduction */ diff --git a/tests/trig.lisp b/tests/trig.lisp index 724fabe7de7ac83461caf9335a855f1767ad9889..cfd7ea288eee046195634f8d7013849184743126 100644 --- a/tests/trig.lisp +++ b/tests/trig.lisp @@ -945,9 +945,18 @@ (kernel:%exp *snan*)) (assert-equal ext:double-float-positive-infinity (kernel:%exp ext:double-float-positive-infinity)) + (assert-equal 0d0 + (kernel:%exp -1000d0)) (kernel::with-float-traps-masked (:overflow) (assert-equal ext:double-float-positive-infinity - (kernel:%exp 710d0)))) + (kernel:%exp 710d0))) + (let ((modes (ext:get-floating-point-modes))) + (unwind-protect + (progn + (ext:set-floating-point-modes :traps '(:underflow)) + (assert-error 'floating-point-underflow + (kernel:%exp -1000d0))) + (apply #'ext:set-floating-point-modes modes)))) (define-test %log.exception (:tag :fdlibm)