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

Use setexception to raise the inexact exception for atan.

parent a31150c5
No related branches found
No related tags found
No related merge requests found
......@@ -104,7 +104,12 @@ huge = 1.0e300;
else return -atanhi[3]-atanlo[3];
} if (ix < 0x3fdc0000) { /* |x| < 0.4375 */
if (ix < 0x3e200000) { /* |x| < 2^-29 */
if(huge+x>one) return x; /* raise inexact */
/* return x inexact except 0 */
if (x != 0) {
fdlibm_setexception(x, FDLIBM_INEXACT);
}
return x;
}
id = -1;
} else {
......
......@@ -258,7 +258,19 @@
(kernel:%atan *snan*))
(assert-true (ext:float-nan-p (kernel:%atan *qnan*)))
(kernel::with-float-traps-masked (:invalid)
(assert-true (ext:float-nan-p (kernel:%atan *snan*)))))
(assert-true (ext:float-nan-p (kernel:%atan *snan*))))
;; atan(x) = x for |x| < 2^-29, signaling inexact.
(let ((x (scale-float 1d0 -30))
(x0 0d0))
(with-inexact-exception-enabled
;; This must not throw an inexact exception because the result
;; is exact when the arg is 0.
(assert-eql 0d0 (kernel:%atan 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:%atan x)))))
(define-test %log10.exceptions
(: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