
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 80df05a11cc138d18d989a5f8f690627026e3069 (commit) from ab446830b129ca3607c4342c24849ca8554db7ce (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 80df05a11cc138d18d989a5f8f690627026e3069 Author: Raymond Toy <toy.raymond@gmail.com> Date: Fri Aug 15 22:41:26 2014 -0700 Make cosh signal overflow when it should overflow. * lisp/e_cosh.c: * The compiler replaced the code huge*huge with infinity instead of doing the operation. Change it so it does fabs(x)*huge, which forces the compiler to do the multiplication. * Change huge from 1e300 to 1e307 so that fabs(x)*huge will actually overflow when |x| > overflowthreshold. * tests/trig.lisp: * Add tests for sinh and cosh signaling overflow appropriately. * general-info/release-20f.txt: * Update. diff --git a/src/general-info/release-20f.txt b/src/general-info/release-20f.txt index 92df6fa..7179f1f 100644 --- a/src/general-info/release-20f.txt +++ b/src/general-info/release-20f.txt @@ -62,6 +62,8 @@ New in this release: DEFINE-CONDITION. (From Helmut Eller.) * The lisp executable is now compiled to use SSE2 on x86 machines; CMUCL will not run on chips without SSE2 anymore. + * (cosh 1000d0) signals an overflow error as it + should. Previously, it just incorrectly returned infinity. * ANSI compliance fixes: * The values on the branch cuts for the inverse trig and diff --git a/src/lisp/e_cosh.c b/src/lisp/e_cosh.c index 28b6c3c..1d2ac30 100644 --- a/src/lisp/e_cosh.c +++ b/src/lisp/e_cosh.c @@ -35,9 +35,9 @@ #include "fdlibm.h" #ifdef __STDC__ -static const double one = 1.0, half=0.5, huge = 1.0e300; +static const double one = 1.0, half=0.5, huge = 1.0e307; #else -static double one = 1.0, half=0.5, huge = 1.0e300; +static double one = 1.0, half=0.5, huge = 1.0e307; #endif #ifdef __STDC__ @@ -91,5 +91,5 @@ static double one = 1.0, half=0.5, huge = 1.0e300; } /* |x| > overflowthresold, cosh(x) overflow */ - return huge*huge; + return fabs(x)*huge; } diff --git a/tests/trig.lisp b/tests/trig.lisp index 695c50d..4f15848 100644 --- a/tests/trig.lisp +++ b/tests/trig.lisp @@ -791,3 +791,13 @@ (get-signs (atanh-def #c(2d0 +1d-20))) (assert-true (check-signs #'atanh #c(2d0 0d0) tr ti)) (assert-true (check-signs #'atanh #c(2w0 0w0) tr ti)))) + +(define-test cosh.overflow + (:tag :cosh) + (assert-error 'floating-point-overflow + (cosh 1000d0))) + +(define-test sinh.overflow + (:tag :sinh) + (assert-error 'floating-point-overflow + (sinh 1000d0))) \ No newline at end of file ----------------------------------------------------------------------- Summary of changes: src/general-info/release-20f.txt | 2 ++ src/lisp/e_cosh.c | 6 +++--- tests/trig.lisp | 10 ++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) hooks/post-receive -- CMU Common Lisp