[Git][cmucl/cmucl][rtoy-setexception-inexact] Use setexception to raise the inexact exception for %expm1.

Raymond Toy rtoy at common-lisp.net
Thu Dec 24 17:15:40 UTC 2015


Raymond Toy pushed to branch rtoy-setexception-inexact at cmucl / cmucl


Commits:
89097cd0 by Raymond Toy at 2015-12-24T09:15:27Z
Use setexception to raise the inexact exception for %expm1.

- - - - -


2 changed files:

- src/lisp/s_expm1.c
- tests/fdlibm.lisp


Changes:

=====================================
src/lisp/s_expm1.c
=====================================
--- a/src/lisp/s_expm1.c
+++ b/src/lisp/s_expm1.c
@@ -160,8 +160,8 @@ Q5  =  -2.01099218183624371326e-07; /* BE8AFDB7 6E09C32D */
                 
 	    }
 	    if(xsb!=0) { /* x < -56*ln2, return -1.0 with inexact */
-		if(x+tiny<0.0)		/* raise inexact */
-		return tiny-one;	/* return -1 */
+                fdlibm_setexception(x, FDLIBM_INEXACT);
+		return tiny - one;
 	    }
 	}
 


=====================================
tests/fdlibm.lisp
=====================================
--- a/tests/fdlibm.lisp
+++ b/tests/fdlibm.lisp
@@ -163,7 +163,12 @@
 		 (kernel:%expm1 709.8d0))
     )
   (kernel::with-float-traps-masked (:invalid)
-    (assert-true (ext::float-nan-p (kernel:%expm1 *snan*)))))
+    (assert-true (ext::float-nan-p (kernel:%expm1 *snan*))))
+  ;; expm1(x) = -1 for x < -56*log(2), signaling inexact
+  (let ((x (* -57 (log 2d0))))
+    (with-inexact-exception-enabled
+	(assert-error 'floating-point-inexact
+		      (kernel:%expm1 x)))))
 
 (define-test %log1p.exceptions
   (:tag :fdlibm)



View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/commit/89097cd0d602d233c8deddd443ba4baf0f147aef
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cmucl-cvs/attachments/20151224/e6273f45/attachment.html>


More information about the cmucl-cvs mailing list