[libmath-prime-util-perl] 42/54: Add some threshold returns to protect vs. messed up rounding modes
Partha P. Mukherjee
ppm-guest at moszumanska.debian.org
Thu May 21 18:52:10 UTC 2015
This is an automated email from the git hooks/post-receive script.
ppm-guest pushed a commit to annotated tag v0.38
in repository libmath-prime-util-perl.
commit db88ec8cc32a692f2a223d224c0d27508ed99ca7
Author: Dana Jacobsen <dana at acm.org>
Date: Thu Feb 27 13:10:19 2014 -0800
Add some threshold returns to protect vs. messed up rounding modes
---
util.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/util.c b/util.c
index 694bda0..9484ab9 100644
--- a/util.c
+++ b/util.c
@@ -49,6 +49,9 @@
#ifndef LDBL_EPSILON
#define LDBL_EPSILON 1e-16
#endif
+#ifndef LDBL_MAX
+ #define LDBL_MAX DBL_MAX
+#endif
#define KAHAN_INIT(s) \
long double s ## _y, s ## _t; \
@@ -1388,6 +1391,9 @@ long double _XS_ExponentialIntegral(long double x) {
KAHAN_INIT(sum);
if (x == 0) croak("Invalid input to ExponentialIntegral: x must be != 0");
+ /* Protect against messed up rounding modes */
+ if (x >= 12000) return INFINITY;
+ if (x <= -12000) return 0;
if (x < -1) {
/* Continued fraction, good for x < -1 */
@@ -1468,6 +1474,7 @@ long double _XS_LogarithmicIntegral(long double x) {
if (x == 1) return -INFINITY;
if (x == 2) return li2;
if (x < 0) croak("Invalid input to LogarithmicIntegral: x must be >= 0");
+ if (x >= LDBL_MAX) return INFINITY;
return _XS_ExponentialIntegral(logl(x));
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmath-prime-util-perl.git
More information about the Pkg-perl-cvs-commits
mailing list