diff --git a/src/general-info/release-20f.txt b/src/general-info/release-20f.txt index 92df6faa0dd5f00da45d15de16a7d2a6de4431f6..7179f1f0776ea718a1d6a27c6bc4e7843cdf6553 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 28b6c3c4f6f7dde35fe652694fd03d42d6f054b1..1d2ac3078bd35b79e68ff141c859774cc2f7d782 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 695c50de044b431e43e5c0d3d85d43d0c911e407..4f158486910362d5a8bb000ec228f4b2a390456d 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