summaryrefslogtreecommitdiff
path: root/patches/mpfr/3.1.0/190-gamma-underflow.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/mpfr/3.1.0/190-gamma-underflow.patch')
-rw-r--r--patches/mpfr/3.1.0/190-gamma-underflow.patch93
1 files changed, 93 insertions, 0 deletions
diff --git a/patches/mpfr/3.1.0/190-gamma-underflow.patch b/patches/mpfr/3.1.0/190-gamma-underflow.patch
new file mode 100644
index 0000000..3de1d19
--- /dev/null
+++ b/patches/mpfr/3.1.0/190-gamma-underflow.patch
@@ -0,0 +1,93 @@
+diff -Naurd mpfr-3.1.0-a/PATCHES mpfr-3.1.0-b/PATCHES
+--- mpfr-3.1.0-a/PATCHES 2012-04-27 01:13:15.000000000 +0000
++++ mpfr-3.1.0-b/PATCHES 2012-04-27 01:13:15.000000000 +0000
+@@ -0,0 +1 @@
++gamma-underflow
+diff -Naurd mpfr-3.1.0-a/VERSION mpfr-3.1.0-b/VERSION
+--- mpfr-3.1.0-a/VERSION 2012-03-12 11:59:47.000000000 +0000
++++ mpfr-3.1.0-b/VERSION 2012-04-27 01:13:15.000000000 +0000
+@@ -1 +1 @@
+-3.1.0-p8
++3.1.0-p9
+diff -Naurd mpfr-3.1.0-a/src/gamma.c mpfr-3.1.0-b/src/gamma.c
+--- mpfr-3.1.0-a/src/gamma.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/gamma.c 2012-04-27 01:13:15.000000000 +0000
+@@ -296,7 +296,7 @@
+ /* we want an upper bound for x * [log(2-x)-1].
+ since x < 0, we need a lower bound on log(2-x) */
+ mpfr_ui_sub (xp, 2, x, MPFR_RNDD);
+- mpfr_log2 (xp, xp, MPFR_RNDD);
++ mpfr_log (xp, xp, MPFR_RNDD);
+ mpfr_sub_ui (xp, xp, 1, MPFR_RNDD);
+ mpfr_mul (xp, xp, x, MPFR_RNDU);
+
+diff -Naurd mpfr-3.1.0-a/src/mpfr.h mpfr-3.1.0-b/src/mpfr.h
+--- mpfr-3.1.0-a/src/mpfr.h 2012-03-12 11:59:47.000000000 +0000
++++ mpfr-3.1.0-b/src/mpfr.h 2012-04-27 01:13:15.000000000 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 3
+ #define MPFR_VERSION_MINOR 1
+ #define MPFR_VERSION_PATCHLEVEL 0
+-#define MPFR_VERSION_STRING "3.1.0-p8"
++#define MPFR_VERSION_STRING "3.1.0-p9"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-3.1.0-a/src/version.c mpfr-3.1.0-b/src/version.c
+--- mpfr-3.1.0-a/src/version.c 2012-03-12 11:59:47.000000000 +0000
++++ mpfr-3.1.0-b/src/version.c 2012-04-27 01:13:15.000000000 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "3.1.0-p8";
++ return "3.1.0-p9";
+ }
+diff -Naurd mpfr-3.1.0-a/tests/tgamma.c mpfr-3.1.0-b/tests/tgamma.c
+--- mpfr-3.1.0-a/tests/tgamma.c 2011-10-03 08:17:14.000000000 +0000
++++ mpfr-3.1.0-b/tests/tgamma.c 2012-04-27 01:13:15.000000000 +0000
+@@ -478,6 +478,36 @@
+ mpfr_clear (x);
+ }
+
++/* bug found by Giridhar Tammana */
++static void
++test20120426 (void)
++{
++ mpfr_t xa, xb;
++ int i;
++ mpfr_exp_t emin;
++
++ mpfr_init2 (xa, 53);
++ mpfr_init2 (xb, 53);
++ mpfr_set_d (xb, -168.5, MPFR_RNDN);
++ emin = mpfr_get_emin ();
++ mpfr_set_emin (-1073);
++ i = mpfr_gamma (xa, xb, MPFR_RNDN);
++ i = mpfr_subnormalize (xa, i, MPFR_RNDN); /* new ternary value */
++ mpfr_set_str (xb, "-9.5737343987585366746184749943e-304", 10, MPFR_RNDN);
++ if (!((i > 0) && (mpfr_cmp (xa, xb) == 0)))
++ {
++ printf ("Error in test20120426, i=%d\n", i);
++ printf ("expected ");
++ mpfr_print_binary (xb); putchar ('\n');
++ printf ("got ");
++ mpfr_print_binary (xa); putchar ('\n');
++ exit (1);
++ }
++ mpfr_set_emin (emin);
++ mpfr_clear (xa);
++ mpfr_clear (xb);
++}
++
+ static void
+ exprange (void)
+ {
+@@ -821,6 +851,7 @@
+ gamma_integer ();
+ test20071231 ();
+ test20100709 ();
++ test20120426 ();
+
+ data_check ("data/gamma", mpfr_gamma, "mpfr_gamma");
+