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

Use setexception to raise the inexact exception for sinh.

parent b4c91767
No related branches found
No related tags found
No related merge requests found
......@@ -67,8 +67,14 @@ static double one = 1.0, shuge = 1.0e307;
if (jx<0) h = -h;
/* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */
if (ix < 0x40360000) { /* |x|<22 */
if (ix<0x3e300000) /* |x|<2**-28 */
if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */
if (ix<0x3e300000) { /* |x|<2**-28 */
/* sinh(tiny) = tiny with inexact */
if (x != 0) {
fdlibm_setexception(x, FDLIBM_INEXACT);
}
return x;
}
t = fdlibm_expm1(fabs(x));
if(ix<0x3ff00000) return h*(2.0*t-t*t/(t+one));
return h*(t+t/(t+one));
......
......@@ -68,8 +68,19 @@
(kernel:%sinh ext:double-float-negative-infinity)))
;; Test NaN
(kernel::with-float-traps-masked (:invalid)
(assert-true (ext:float-nan-p (kernel:%sinh *qnan*)))))
(assert-true (ext:float-nan-p (kernel:%sinh *qnan*))))
;; sinh(x) = x for |x| < 2^-28. Should signal inexact unless x = 0.
(let ((x (scale-float 1d0 -29))
(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:%sinh 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:%sinh x)))))
(define-test %tanh.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