[git] CMU Common Lisp branch master updated. snapshot-2014-08-19-gb9a6091
Raymond Toy
rtoy at common-lisp.net
Fri Aug 22 04:42:16 UTC 2014
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMU Common Lisp".
The branch, master has been updated
via b9a6091a28a431b4f11300b350e77f57d8389b19 (commit)
from 97730f377f75b7afdb5ab472df2a85aa7a7eb50a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit b9a6091a28a431b4f11300b350e77f57d8389b19
Author: Raymond Toy <toy.raymond at gmail.com>
Date: Thu Aug 21 21:42:06 2014 -0700
Make log1p signal errors using fdlibm_setexception.
* src/lisp/s_log1p.c:
* Use fdlibm_setexception
* tests/trig.lisp:
* Add tests for log1p.
diff --git a/src/lisp/s_log1p.c b/src/lisp/s_log1p.c
index d8f2cad..ecbfbd4 100644
--- a/src/lisp/s_log1p.c
+++ b/src/lisp/s_log1p.c
@@ -114,8 +114,13 @@ static double zero = 0.0;
k = 1;
if (hx < 0x3FDA827A) { /* x < 0.41422 */
if(ax>=0x3ff00000) { /* x <= -1.0 */
- if(x==-1.0) return -two54/zero; /* log1p(-1)=+inf */
- else return (x-x)/(x-x); /* log1p(x<-1)=NaN */
+ if(x==-1.0) {
+ /* log1p(-1)=-inf */
+ return fdlibm_setexception(x, FDLIBM_OVERFLOW);
+ } else {
+ /* log1p(x<-1)=NaN */
+ return fdlibm_setexception(x, FDLIBM_INVALID);
+ }
}
if(ax<0x3e200000) { /* |x| < 2**-29 */
if(two54+x>zero /* raise inexact */
diff --git a/tests/trig.lisp b/tests/trig.lisp
index 07cd6bd..1452c4c 100644
--- a/tests/trig.lisp
+++ b/tests/trig.lisp
@@ -887,3 +887,16 @@
(kernel:%expm1 ext:double-float-positive-infinity)))
(kernel::with-float-traps-masked (:invalid)
(assert-true (ext::float-nan-p (kernel:%expm1 *snan*)))))
+
+(define-test log1p.exceptions
+ (:tag :fdlibm)
+ (assert-error 'floating-point-invalid-operation
+ (kernel:%log1p -2d0))
+ (assert-error 'floating-point-overflow
+ (kernel:%log1p -1d0))
+ (assert-true (ext:float-nan-p (kernel:%log1p *qnan*)))
+ (kernel::with-float-traps-masked (:overflow)
+ (assert-equal ext:double-float-negative-infinity
+ (kernel:%log1p -1d0)))
+ (kernel::with-float-traps-masked (:invalid)
+ (assert-true (ext:float-nan-p (kernel:%log1p *snan*)))))
-----------------------------------------------------------------------
Summary of changes:
src/lisp/s_log1p.c | 9 +++++++--
tests/trig.lisp | 13 +++++++++++++
2 files changed, 20 insertions(+), 2 deletions(-)
hooks/post-receive
--
CMU Common Lisp
More information about the cmucl-cvs
mailing list