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

Make atanh signal errors using fdlibm_setexception.

 * src/lisp/e_atanh.c
   * Use fdlibm_setexception
 * tests/trig.lisp:
   * Add tests for atanh
parent bd30c83c
No related branches found
No related tags found
No related merge requests found
...@@ -57,10 +57,11 @@ static double zero = 0.0; ...@@ -57,10 +57,11 @@ static double zero = 0.0;
lx = ux.i[LOWORD]; /* low word */ lx = ux.i[LOWORD]; /* low word */
ix = hx&0x7fffffff; ix = hx&0x7fffffff;
if ((ix|((lx|(-lx))>>31))>0x3ff00000) /* |x|>1 */ if ((ix|((lx|(-lx))>>31))>0x3ff00000) /* |x|>1 */
return (x-x)/(x-x); return fdlibm_setexception(x, FDLIBM_INVALID);
if(ix==0x3ff00000) if(ix==0x3ff00000)
return x/zero; return fdlibm_setexception(x, FDLIBM_DIVIDE_BY_ZERO);
if(ix<0x3e300000&&(huge+x)>zero) return x; /* x<2**-28 */
if(ix<0x3e300000&&(huge+x)>zero) return x; /* x<2**-28 */
ux.d = x; ux.d = x;
ux.i[HIWORD] = ix; /* x <- |x| */ ux.i[HIWORD] = ix; /* x <- |x| */
x = ux.d; x = ux.d;
......
...@@ -888,6 +888,26 @@ ...@@ -888,6 +888,26 @@
(kernel::with-float-traps-masked (:invalid) (kernel::with-float-traps-masked (:invalid)
(assert-true (ext:float-nan-p (kernel:%asinh *snan*))))) (assert-true (ext:float-nan-p (kernel:%asinh *snan*)))))
(define-test atanh.exceptions
(:tag :fdlibm)
(assert-error 'floating-point-invalid-operation
(kernel:%atanh 2d0))
(assert-error 'floating-point-invalid-operation
(kernel:%atanh -2d0))
(assert-error 'division-by-zero
(kernel:%atanh 1d0))
(assert-error 'division-by-zero
(kernel:%atanh -1d0))
(kernel::with-float-traps-masked (:invalid)
(assert-true (ext:float-nan-p (kernel:%atanh 2d0)))
(assert-true (ext:float-nan-p (kernel:%atanh -2d0))))
(kernel::with-float-traps-masked (:divide-by-zero)
(assert-equal ext:double-float-positive-infinity
(kernel:%atanh 1d0))
(assert-equal ext:double-float-negative-infinity
(kernel:%atanh -1d0))))
(define-test expm1.exceptions (define-test expm1.exceptions
(:tag :fdlibm) (:tag :fdlibm)
(assert-error 'floating-point-overflow (assert-error 'floating-point-overflow
......
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