summaryrefslogtreecommitdiff
path: root/patches/mpfr/3.0.0/170-mpfr_set_ld.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/mpfr/3.0.0/170-mpfr_set_ld.patch')
-rw-r--r--patches/mpfr/3.0.0/170-mpfr_set_ld.patch155
1 files changed, 155 insertions, 0 deletions
diff --git a/patches/mpfr/3.0.0/170-mpfr_set_ld.patch b/patches/mpfr/3.0.0/170-mpfr_set_ld.patch
new file mode 100644
index 0000000..9209afe
--- /dev/null
+++ b/patches/mpfr/3.0.0/170-mpfr_set_ld.patch
@@ -0,0 +1,155 @@
+diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
+--- mpfr-3.0.0-a/PATCHES 2010-10-21 21:18:26.000000000 +0000
++++ mpfr-3.0.0-b/PATCHES 2010-10-21 21:18:26.000000000 +0000
+@@ -0,0 +1 @@
++mpfr_set_ld
+diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
+--- mpfr-3.0.0-a/VERSION 2010-10-21 20:59:32.000000000 +0000
++++ mpfr-3.0.0-b/VERSION 2010-10-21 21:18:26.000000000 +0000
+@@ -1 +1 @@
+-3.0.0-p6
++3.0.0-p7
+diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
+--- mpfr-3.0.0-a/mpfr.h 2010-10-21 20:59:32.000000000 +0000
++++ mpfr-3.0.0-b/mpfr.h 2010-10-21 21:18:26.000000000 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 3
+ #define MPFR_VERSION_MINOR 0
+ #define MPFR_VERSION_PATCHLEVEL 0
+-#define MPFR_VERSION_STRING "3.0.0-p6"
++#define MPFR_VERSION_STRING "3.0.0-p7"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-3.0.0-a/set_ld.c mpfr-3.0.0-b/set_ld.c
+--- mpfr-3.0.0-a/set_ld.c 2010-06-10 11:00:14.000000000 +0000
++++ mpfr-3.0.0-b/set_ld.c 2010-10-21 21:18:26.000000000 +0000
+@@ -102,21 +102,25 @@
+ {
+ x /= div13; /* exact */
+ shift_exp += 8192;
++ mpfr_div_2si (t, t, 8192, MPFR_RNDZ);
+ }
+ if (ABS (x) >= div12)
+ {
+ x /= div12; /* exact */
+ shift_exp += 4096;
++ mpfr_div_2si (t, t, 4096, MPFR_RNDZ);
+ }
+ if (ABS (x) >= div11)
+ {
+ x /= div11; /* exact */
+ shift_exp += 2048;
++ mpfr_div_2si (t, t, 2048, MPFR_RNDZ);
+ }
+ if (ABS (x) >= div10)
+ {
+ x /= div10; /* exact */
+ shift_exp += 1024;
++ mpfr_div_2si (t, t, 1024, MPFR_RNDZ);
+ }
+ /* warning: we may have DBL_MAX=2^1024*(1-2^(-53)) < x < 2^1024,
+ therefore we have one extra exponent reduction step */
+@@ -124,9 +128,10 @@
+ {
+ x /= div9; /* exact */
+ shift_exp += 512;
++ mpfr_div_2si (t, t, 512, MPFR_RNDZ);
+ }
+ } /* Check overflow of double */
+- else
++ else /* no overflow on double */
+ {
+ long double div9, div10, div11;
+
+@@ -149,29 +154,34 @@
+ {
+ x /= div13; /* exact */
+ shift_exp -= 8192;
++ mpfr_mul_2si (t, t, 8192, MPFR_RNDZ);
+ }
+ if (ABS (x) <= div12)
+ {
+ x /= div12; /* exact */
+ shift_exp -= 4096;
++ mpfr_mul_2si (t, t, 4096, MPFR_RNDZ);
+ }
+ if (ABS (x) <= div11)
+ {
+ x /= div11; /* exact */
+ shift_exp -= 2048;
++ mpfr_mul_2si (t, t, 2048, MPFR_RNDZ);
+ }
+ if (ABS (x) <= div10)
+ {
+ x /= div10; /* exact */
+ shift_exp -= 1024;
++ mpfr_mul_2si (t, t, 1024, MPFR_RNDZ);
+ }
+ if (ABS(x) <= div9)
+ {
+ x /= div9; /* exact */
+ shift_exp -= 512;
++ mpfr_mul_2si (t, t, 512, MPFR_RNDZ);
+ }
+ }
+- else
++ else /* no underflow */
+ {
+ inexact = mpfr_set_d (u, (double) x, MPFR_RNDZ);
+ MPFR_ASSERTD (inexact == 0);
+diff -Naurd mpfr-3.0.0-a/tests/tset_ld.c mpfr-3.0.0-b/tests/tset_ld.c
+--- mpfr-3.0.0-a/tests/tset_ld.c 2010-06-10 11:00:13.000000000 +0000
++++ mpfr-3.0.0-b/tests/tset_ld.c 2010-10-21 21:18:26.000000000 +0000
+@@ -147,12 +147,39 @@
+ test_fixed_bugs (void)
+ {
+ mpfr_t x;
+- long double d;
++ long double l, m;
+
+ /* bug found by Steve Kargl (2009-03-14) */
+ mpfr_init2 (x, 64);
+ mpfr_set_ui_2exp (x, 1, -16447, MPFR_RNDN);
+- d = mpfr_get_ld (x, MPFR_RNDN); /* an assertion failed in init2.c:50 */
++ mpfr_get_ld (x, MPFR_RNDN); /* an assertion failed in init2.c:50 */
++
++ /* bug reported by Jakub Jelinek (2010-10-17)
++ https://gforge.inria.fr/tracker/?func=detail&aid=11300 */
++ mpfr_set_prec (x, MPFR_LDBL_MANT_DIG);
++ /* l = 0x1.23456789abcdef0123456789abcdp-914L; */
++ l = 8.215640181713713164092636634579e-276;
++ mpfr_set_ld (x, l, MPFR_RNDN);
++ m = mpfr_get_ld (x, MPFR_RNDN);
++ if (m != l)
++ {
++ printf ("Error in get_ld o set_ld for l=%Le\n", l);
++ printf ("Got m=%Le instead of l\n", m);
++ exit (1);
++ }
++
++ /* another similar test which failed with extended double precision and the
++ generic code for mpfr_set_ld */
++ /* l = 0x1.23456789abcdef0123456789abcdp-968L; */
++ l = 4.560596445887084662336528403703e-292;
++ mpfr_set_ld (x, l, MPFR_RNDN);
++ m = mpfr_get_ld (x, MPFR_RNDN);
++ if (m != l)
++ {
++ printf ("Error in get_ld o set_ld for l=%Le\n", l);
++ printf ("Got m=%Le instead of l\n", m);
++ exit (1);
++ }
+
+ mpfr_clear (x);
+ }
+diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
+--- mpfr-3.0.0-a/version.c 2010-10-21 20:59:32.000000000 +0000
++++ mpfr-3.0.0-b/version.c 2010-10-21 21:18:26.000000000 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "3.0.0-p6";
++ return "3.0.0-p7";
+ }