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

Use setexception to raise the inexact exception for tanh.

Note that original code didn't actually signal inexact probably
because the compiler constant-folded one - tiny to one.
parent 91ff3607
No related branches found
No related tags found
No related merge requests found
......@@ -78,7 +78,9 @@ static double one=1.0, two=2.0, tiny = 1.0e-300;
}
/* |x| > 22, return +-1 */
} else {
z = one - tiny; /* raised inexact flag */
/* Always raise inexact flag */
fdlibm_setexception(x, FDLIBM_INEXACT);
z = one - tiny;
}
return (jx>=0)? z: -z;
}
......@@ -88,7 +88,14 @@
(assert-error 'floating-point-invalid-operation
(kernel:%tanh *snan*))
(kernel::with-float-traps-masked (:invalid)
(assert-true (ext:float-nan-p (kernel:%tanh *snan*)))))
(assert-true (ext:float-nan-p (kernel:%tanh *snan*))))
;; tanh(x) = +/- 1 for |x| > 22, raising inexact, always.
(let ((x 22.1d0))
(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:%tanh x)))))
(define-test %acosh.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