patches/mpfr/2.4.1/100-remainder-neg.patch
changeset 1249 e612e57b4249
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/patches/mpfr/2.4.1/100-remainder-neg.patch	Sun Mar 08 17:27:02 2009 +0000
     1.3 @@ -0,0 +1,123 @@
     1.4 +diff -Naurd mpfr-2.4.1-a/PATCHES mpfr-2.4.1-b/PATCHES
     1.5 +--- mpfr-2.4.1-a/PATCHES	2009-02-20 09:43:17.000000000 +0000
     1.6 ++++ mpfr-2.4.1-b/PATCHES	2009-02-27 16:56:29.000000000 +0000
     1.7 +@@ -0,0 +1 @@
     1.8 ++remainder-neg
     1.9 +diff -Naurd mpfr-2.4.1-a/VERSION mpfr-2.4.1-b/VERSION
    1.10 +--- mpfr-2.4.1-a/VERSION	2009-02-25 16:16:08.000000000 +0000
    1.11 ++++ mpfr-2.4.1-b/VERSION	2009-02-27 16:55:37.000000000 +0000
    1.12 +@@ -1 +1 @@
    1.13 +-2.4.1
    1.14 ++2.4.1-p1
    1.15 +diff -Naurd mpfr-2.4.1-a/mpfr.h mpfr-2.4.1-b/mpfr.h
    1.16 +--- mpfr-2.4.1-a/mpfr.h	2009-02-25 16:16:08.000000000 +0000
    1.17 ++++ mpfr-2.4.1-b/mpfr.h	2009-02-27 16:55:38.000000000 +0000
    1.18 +@@ -27,7 +27,7 @@
    1.19 + #define MPFR_VERSION_MAJOR 2
    1.20 + #define MPFR_VERSION_MINOR 4
    1.21 + #define MPFR_VERSION_PATCHLEVEL 1
    1.22 +-#define MPFR_VERSION_STRING "2.4.1"
    1.23 ++#define MPFR_VERSION_STRING "2.4.1-p1"
    1.24 + 
    1.25 + /* Macros dealing with MPFR VERSION */
    1.26 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
    1.27 +diff -Naurd mpfr-2.4.1-a/rem1.c mpfr-2.4.1-b/rem1.c
    1.28 +--- mpfr-2.4.1-a/rem1.c	2009-02-20 09:43:17.000000000 +0000
    1.29 ++++ mpfr-2.4.1-b/rem1.c	2009-02-27 16:55:15.000000000 +0000
    1.30 +@@ -170,7 +170,12 @@
    1.31 +     }
    1.32 + 
    1.33 +   if (mpz_cmp_ui (r, 0) == 0)
    1.34 +-    inex = mpfr_set_ui (rem, 0, GMP_RNDN);
    1.35 ++    {
    1.36 ++      inex = mpfr_set_ui (rem, 0, GMP_RNDN);
    1.37 ++      /* take into account sign of x */
    1.38 ++      if (signx < 0)
    1.39 ++        mpfr_neg (rem, rem, GMP_RNDN);
    1.40 ++    }
    1.41 +   else
    1.42 +     {
    1.43 +       if (rnd_q == GMP_RNDN)
    1.44 +@@ -190,6 +195,9 @@
    1.45 +                 *quo += 1;
    1.46 +             }
    1.47 +         }
    1.48 ++      /* take into account sign of x */
    1.49 ++      if (signx < 0)
    1.50 ++        mpz_neg (r, r);
    1.51 +       inex = mpfr_set_z (rem, r, rnd);
    1.52 +       /* if ex > ey, rem should be multiplied by 2^ey, else by 2^ex */
    1.53 +       MPFR_EXP (rem) += (ex > ey) ? ey : ex;
    1.54 +@@ -198,13 +206,6 @@
    1.55 +   if (quo)
    1.56 +     *quo *= sign;
    1.57 + 
    1.58 +-  /* take into account sign of x */
    1.59 +-  if (signx < 0)
    1.60 +-    {
    1.61 +-      mpfr_neg (rem, rem, GMP_RNDN);
    1.62 +-      inex = -inex;
    1.63 +-    }
    1.64 +-
    1.65 +   mpz_clear (mx);
    1.66 +   mpz_clear (my);
    1.67 +   mpz_clear (r);
    1.68 +diff -Naurd mpfr-2.4.1-a/tests/tremquo.c mpfr-2.4.1-b/tests/tremquo.c
    1.69 +--- mpfr-2.4.1-a/tests/tremquo.c	2009-02-20 09:43:15.000000000 +0000
    1.70 ++++ mpfr-2.4.1-b/tests/tremquo.c	2009-02-27 16:55:15.000000000 +0000
    1.71 +@@ -25,6 +25,36 @@
    1.72 + 
    1.73 + #include "mpfr-test.h"
    1.74 + 
    1.75 ++static void
    1.76 ++bug20090227 (void)
    1.77 ++{
    1.78 ++  mpfr_t x, y, r1, r2;
    1.79 ++  int inex1, inex2;
    1.80 ++
    1.81 ++  mpfr_init2 (x, 118);
    1.82 ++  mpfr_init2 (y, 181);
    1.83 ++  mpfr_init2 (r1, 140);
    1.84 ++  mpfr_init2 (r2, 140);
    1.85 ++  mpfr_set_si (x, -1, GMP_RNDN);
    1.86 ++  mpfr_set_str_binary (y, "1.100100100001111110110101010001000100001011010001100001000110100110001001100011001100010100010111000000011011100000111001101000100101001000000100100111000001000100010100110011111010");
    1.87 ++  inex1 = mpfr_remainder (r1, x, y, GMP_RNDU);
    1.88 ++  /* since the quotient is -1, r1 is the rounding of x+y */
    1.89 ++  inex2 = mpfr_add (r2, x, y, GMP_RNDU);
    1.90 ++  if (mpfr_cmp (r1, r2))
    1.91 ++    {
    1.92 ++      printf ("Error in mpfr_remainder (bug20090227)\n");
    1.93 ++      printf ("Expected ");
    1.94 ++      mpfr_dump (r2);
    1.95 ++      printf ("Got      ");
    1.96 ++      mpfr_dump (r1);
    1.97 ++      exit (1);
    1.98 ++    }
    1.99 ++  mpfr_clear (x);
   1.100 ++  mpfr_clear (y);
   1.101 ++  mpfr_clear (r1);
   1.102 ++  mpfr_clear (r2);
   1.103 ++}
   1.104 ++
   1.105 + int
   1.106 + main (int argc, char *argv[])
   1.107 + {
   1.108 +@@ -50,6 +80,8 @@
   1.109 + 
   1.110 +   tests_start_mpfr ();
   1.111 + 
   1.112 ++  bug20090227 ();
   1.113 ++
   1.114 +   mpfr_init (x);
   1.115 +   mpfr_init (y);
   1.116 +   mpfr_init (r);
   1.117 +diff -Naurd mpfr-2.4.1-a/version.c mpfr-2.4.1-b/version.c
   1.118 +--- mpfr-2.4.1-a/version.c	2009-02-25 16:16:08.000000000 +0000
   1.119 ++++ mpfr-2.4.1-b/version.c	2009-02-27 16:55:38.000000000 +0000
   1.120 +@@ -25,5 +25,5 @@
   1.121 + const char *
   1.122 + mpfr_get_version (void)
   1.123 + {
   1.124 +-  return "2.4.1";
   1.125 ++  return "2.4.1-p1";
   1.126 + }