Skip to content
Snippets Groups Projects
Commit b4c91767 authored by Raymond Toy's avatar Raymond Toy
Browse files

Use setexception to raise the inexact exception for exp.

o Add tests for this
o Use setexception for inexact in e_exp.c.
parent 8b36c06e
No related branches found
No related tags found
No related merge requests found
......@@ -161,7 +161,12 @@ P5 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */
x = hi - lo;
}
else if(hx < 0x3e300000) { /* when |x|<2**-28 */
if(huge+x>one) return one+x;/* trigger inexact */
/* return x inexact except 0 */
if (x != 0) {
fdlibm_setexception(x, FDLIBM_INEXACT);
}
return one + x;
}
else k = 0;
......
......@@ -187,7 +187,19 @@
(ext:set-floating-point-modes :traps '(:underflow))
(assert-error 'floating-point-underflow
(kernel:%exp -1000d0)))
(apply #'ext:set-floating-point-modes modes))))
(apply #'ext:set-floating-point-modes modes)))
(let ((x (scale-float 1d0 -29))
(x0 0d0))
;; exp(x) = x, |x| < 2^-28, with inexact exception unlees x = 0
(with-inexact-exception-enabled
;; This must not throw an inexact exception because the result
;; is exact when the arg is 0.
(assert-eql 1d0 (kernel:%exp x0)))
(with-inexact-exception-enabled
;; This must throw an inexact exception for non-zero x even
;; though the result is exactly x.
(assert-error 'floating-point-inexact
(kernel:%exp x)))))
(define-test %log.exception
(:tag :fdlibm)
......
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