[62069df] | 1 | Submitted By: Jim Gifford (jim at cross-lfs dot org)
|
---|
| 2 | Date: 2009-02-28
|
---|
| 3 | Initial Package Version: 2.4.1
|
---|
| 4 | Origin: MPFR Website
|
---|
| 5 | Upstream Status: Fixed
|
---|
| 6 | Description: See http://www.mpfr.org Website Under Bugs
|
---|
| 7 |
|
---|
| 8 | diff -Naur mpfr-2.4.1.orig/mpfr.h mpfr-2.4.1/mpfr.h
|
---|
| 9 | --- mpfr-2.4.1.orig/mpfr.h 2009-02-25 08:16:08.000000000 -0800
|
---|
| 10 | +++ mpfr-2.4.1/mpfr.h 2009-02-28 15:22:16.554489175 -0800
|
---|
| 11 | @@ -27,7 +27,7 @@
|
---|
| 12 | #define MPFR_VERSION_MAJOR 2
|
---|
| 13 | #define MPFR_VERSION_MINOR 4
|
---|
| 14 | #define MPFR_VERSION_PATCHLEVEL 1
|
---|
| 15 | -#define MPFR_VERSION_STRING "2.4.1"
|
---|
| 16 | +#define MPFR_VERSION_STRING "2.4.1-p1"
|
---|
| 17 |
|
---|
| 18 | /* Macros dealing with MPFR VERSION */
|
---|
| 19 | #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
|
---|
| 20 | diff -Naur mpfr-2.4.1.orig/PATCHES mpfr-2.4.1/PATCHES
|
---|
| 21 | --- mpfr-2.4.1.orig/PATCHES 2009-02-20 01:43:17.000000000 -0800
|
---|
| 22 | +++ mpfr-2.4.1/PATCHES 2009-02-28 15:22:16.554489175 -0800
|
---|
| 23 | @@ -0,0 +1 @@
|
---|
| 24 | +remainder-neg
|
---|
| 25 | diff -Naur mpfr-2.4.1.orig/rem1.c mpfr-2.4.1/rem1.c
|
---|
| 26 | --- mpfr-2.4.1.orig/rem1.c 2009-02-20 01:43:17.000000000 -0800
|
---|
| 27 | +++ mpfr-2.4.1/rem1.c 2009-02-28 15:22:16.554489175 -0800
|
---|
| 28 | @@ -170,7 +170,12 @@
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | if (mpz_cmp_ui (r, 0) == 0)
|
---|
| 32 | - inex = mpfr_set_ui (rem, 0, GMP_RNDN);
|
---|
| 33 | + {
|
---|
| 34 | + inex = mpfr_set_ui (rem, 0, GMP_RNDN);
|
---|
| 35 | + /* take into account sign of x */
|
---|
| 36 | + if (signx < 0)
|
---|
| 37 | + mpfr_neg (rem, rem, GMP_RNDN);
|
---|
| 38 | + }
|
---|
| 39 | else
|
---|
| 40 | {
|
---|
| 41 | if (rnd_q == GMP_RNDN)
|
---|
| 42 | @@ -190,6 +195,9 @@
|
---|
| 43 | *quo += 1;
|
---|
| 44 | }
|
---|
| 45 | }
|
---|
| 46 | + /* take into account sign of x */
|
---|
| 47 | + if (signx < 0)
|
---|
| 48 | + mpz_neg (r, r);
|
---|
| 49 | inex = mpfr_set_z (rem, r, rnd);
|
---|
| 50 | /* if ex > ey, rem should be multiplied by 2^ey, else by 2^ex */
|
---|
| 51 | MPFR_EXP (rem) += (ex > ey) ? ey : ex;
|
---|
| 52 | @@ -198,13 +206,6 @@
|
---|
| 53 | if (quo)
|
---|
| 54 | *quo *= sign;
|
---|
| 55 |
|
---|
| 56 | - /* take into account sign of x */
|
---|
| 57 | - if (signx < 0)
|
---|
| 58 | - {
|
---|
| 59 | - mpfr_neg (rem, rem, GMP_RNDN);
|
---|
| 60 | - inex = -inex;
|
---|
| 61 | - }
|
---|
| 62 | -
|
---|
| 63 | mpz_clear (mx);
|
---|
| 64 | mpz_clear (my);
|
---|
| 65 | mpz_clear (r);
|
---|
| 66 | diff -Naur mpfr-2.4.1.orig/tests/tremquo.c mpfr-2.4.1/tests/tremquo.c
|
---|
| 67 | --- mpfr-2.4.1.orig/tests/tremquo.c 2009-02-20 01:43:15.000000000 -0800
|
---|
| 68 | +++ mpfr-2.4.1/tests/tremquo.c 2009-02-28 15:22:16.554489175 -0800
|
---|
| 69 | @@ -25,6 +25,36 @@
|
---|
| 70 |
|
---|
| 71 | #include "mpfr-test.h"
|
---|
| 72 |
|
---|
| 73 | +static void
|
---|
| 74 | +bug20090227 (void)
|
---|
| 75 | +{
|
---|
| 76 | + mpfr_t x, y, r1, r2;
|
---|
| 77 | + int inex1, inex2;
|
---|
| 78 | +
|
---|
| 79 | + mpfr_init2 (x, 118);
|
---|
| 80 | + mpfr_init2 (y, 181);
|
---|
| 81 | + mpfr_init2 (r1, 140);
|
---|
| 82 | + mpfr_init2 (r2, 140);
|
---|
| 83 | + mpfr_set_si (x, -1, GMP_RNDN);
|
---|
| 84 | + mpfr_set_str_binary (y, "1.100100100001111110110101010001000100001011010001100001000110100110001001100011001100010100010111000000011011100000111001101000100101001000000100100111000001000100010100110011111010");
|
---|
| 85 | + inex1 = mpfr_remainder (r1, x, y, GMP_RNDU);
|
---|
| 86 | + /* since the quotient is -1, r1 is the rounding of x+y */
|
---|
| 87 | + inex2 = mpfr_add (r2, x, y, GMP_RNDU);
|
---|
| 88 | + if (mpfr_cmp (r1, r2))
|
---|
| 89 | + {
|
---|
| 90 | + printf ("Error in mpfr_remainder (bug20090227)\n");
|
---|
| 91 | + printf ("Expected ");
|
---|
| 92 | + mpfr_dump (r2);
|
---|
| 93 | + printf ("Got ");
|
---|
| 94 | + mpfr_dump (r1);
|
---|
| 95 | + exit (1);
|
---|
| 96 | + }
|
---|
| 97 | + mpfr_clear (x);
|
---|
| 98 | + mpfr_clear (y);
|
---|
| 99 | + mpfr_clear (r1);
|
---|
| 100 | + mpfr_clear (r2);
|
---|
| 101 | +}
|
---|
| 102 | +
|
---|
| 103 | int
|
---|
| 104 | main (int argc, char *argv[])
|
---|
| 105 | {
|
---|
| 106 | @@ -50,6 +80,8 @@
|
---|
| 107 |
|
---|
| 108 | tests_start_mpfr ();
|
---|
| 109 |
|
---|
| 110 | + bug20090227 ();
|
---|
| 111 | +
|
---|
| 112 | mpfr_init (x);
|
---|
| 113 | mpfr_init (y);
|
---|
| 114 | mpfr_init (r);
|
---|
| 115 | diff -Naur mpfr-2.4.1.orig/VERSION mpfr-2.4.1/VERSION
|
---|
| 116 | --- mpfr-2.4.1.orig/VERSION 2009-02-25 08:16:08.000000000 -0800
|
---|
| 117 | +++ mpfr-2.4.1/VERSION 2009-02-28 15:22:16.554489175 -0800
|
---|
| 118 | @@ -1 +1 @@
|
---|
| 119 | -2.4.1
|
---|
| 120 | +2.4.1-p1
|
---|
| 121 | diff -Naur mpfr-2.4.1.orig/version.c mpfr-2.4.1/version.c
|
---|
| 122 | --- mpfr-2.4.1.orig/version.c 2009-02-25 08:16:08.000000000 -0800
|
---|
| 123 | +++ mpfr-2.4.1/version.c 2009-02-28 15:22:16.554489175 -0800
|
---|
| 124 | @@ -25,5 +25,5 @@
|
---|
| 125 | const char *
|
---|
| 126 | mpfr_get_version (void)
|
---|
| 127 | {
|
---|
| 128 | - return "2.4.1";
|
---|
| 129 | + return "2.4.1-p1";
|
---|
| 130 | }
|
---|