Commit e655d017 authored by Raymond Toy's avatar Raymond Toy
Browse files

Use setexception to raise the inexact exception for asin.

o Add tests for this
o Use setexception for inexact in e_asin.c.
parent 0d53bc7f
......@@ -89,7 +89,12 @@ qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
return fdlibm_setexception(x, FDLIBM_INVALID);
} else if (ix<0x3fe00000) { /* |x|<0.5 */
if(ix<0x3e400000) { /* if |x| < 2**-27 */
if(huge+x>one) return x;/* return x with inexact if x!=0*/
/* return x inexact except 0 */
if (x != 0) {
fdlibm_setexception(x, FDLIBM_INEXACT);
}
return x;
} else
t = x*x;
p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5)))));
......
......@@ -557,3 +557,20 @@
;; tanh(1d300), no overflow
(assert-eql 1d0 (tanh most-positive-double-float))
(assert-eql -1d0 (tanh (- most-positive-double-float))))
(define-test asin-basic-tests
(:tag :fdlibm)
(let ((x (scale-float 1d0 -28))
(x0 0d0))
;; asin(x) = x for |x| < 2^-27, with inexact exception if x is not 0.
(assert-eql x (asin x))
(assert-eql (- x) (asin (- x)))
(with-inexact-exception-enabled
;; This must not throw an inexact exception because the result
;; is exact when the arg is 0.
(assert-eql 0d0 (asin 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
(asin x)))))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment