Index: doc/gmp.texi =================================================================== RCS file: /home/cvsfiles/gmp42/doc/gmp.texi,v retrieving revision 1.25 retrieving revision 1.28 diff -p -2 -r1.25 -r1.28 *** doc/gmp.texi 18 Sep 2008 15:36:28 -0000 1.25 --- doc/gmp.texi 8 Nov 2008 23:38:20 -0000 1.28 *************** equal, zero otherwise. I.e., test if @v *** 4850,4856 **** equal. ! Caution: Currently only whole limbs are compared, and only in an exact ! fashion. In the future values like 1000 and 0111 may be considered the same ! to 3 bits (on the basis that their difference is that small). @end deftypefun --- 4850,4859 ---- equal. ! Caution 1: All version of GMP up to version 4.2.4 compared just whole limbs, ! meaning sometimes more than @var{op3} bits, sometimes fewer. ! ! Caution 2: This function will consider XXX11...111 and XX100...000 different, ! even if ... is replaced by a semi-infinite number of bits. Such numbers are ! really just one ulp off, and should be considered equal. @end deftypefun Index: mpf/eq.c =================================================================== RCS file: /home/cvsfiles/gmp42/mpf/eq.c,v retrieving revision 1.2 retrieving revision 1.5 diff -p -2 -r1.2 -r1.5 *** mpf/eq.c 30 Aug 2007 18:19:40 -0000 1.2 --- mpf/eq.c 8 Nov 2008 23:31:18 -0000 1.5 *************** *** 1,5 **** /* mpf_eq -- Compare two floats up to a specified bit #. ! Copyright 1993, 1995, 1996, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU MP Library. --- 1,5 ---- /* mpf_eq -- Compare two floats up to a specified bit #. ! Copyright 1993, 1995, 1996, 2001, 2002, 2008 Free Software Foundation, Inc. This file is part of the GNU MP Library. *************** along with the GNU MP Library. If not, *** 20,23 **** --- 20,24 ---- #include "gmp.h" #include "gmp-impl.h" + #include "longlong.h" int *************** mpf_eq (mpf_srcptr u, mpf_srcptr v, unsi *** 27,30 **** --- 28,33 ---- mp_size_t usize, vsize, size, i; mp_exp_t uexp, vexp; + mp_limb_t diff; + int cnt; uexp = u->_mp_exp; *************** mpf_eq (mpf_srcptr u, mpf_srcptr v, unsi *** 54,61 **** /* 2. Are the exponents different? */ ! if (uexp > vexp) ! return 0; /* ??? handle (uexp = vexp + 1) */ ! if (vexp > uexp) ! return 0; /* ??? handle (vexp = uexp + 1) */ usize = ABS (usize); --- 57,62 ---- /* 2. Are the exponents different? */ ! if (uexp != vexp) ! return 0; usize = ABS (usize); *************** mpf_eq (mpf_srcptr u, mpf_srcptr v, unsi *** 94,104 **** } ! if (size > (n_bits + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS) ! size = (n_bits + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS; ! up += usize - size; ! vp += vsize - size; ! for (i = size - 1; i >= 0; i--) { if (up[i] != vp[i]) --- 95,113 ---- } ! up += usize; /* point just above most significant limb */ ! vp += vsize; /* point just above most significant limb */ ! count_leading_zeros (cnt, up[-1]); ! if ((vp[-1] >> (GMP_LIMB_BITS - 1 - cnt)) != 1) ! return 0; /* msb positions different */ ! n_bits += cnt - GMP_NAIL_BITS; ! ! size = MIN (size, (n_bits + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS); ! ! up -= size; /* point at least significant relevant limb */ ! vp -= size; /* point at least significant relevant limb */ ! ! for (i = size - 1; i > 0; i--) { if (up[i] != vp[i]) *************** mpf_eq (mpf_srcptr u, mpf_srcptr v, unsi *** 106,109 **** } ! return 1; } --- 115,119 ---- } ! diff = (up[0] ^ vp[0]) >> GMP_NUMB_BITS - 1 - (n_bits - 1) % GMP_NUMB_BITS; ! return diff == 0; } Index: tests/cxx/t-prec.cc =================================================================== RCS file: /home/cvsfiles/gmp42/tests/cxx/t-prec.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -p -2 -r1.4 -r1.5 *** tests/cxx/t-prec.cc 30 Aug 2007 23:14:40 -0000 1.4 --- tests/cxx/t-prec.cc 8 Nov 2008 23:33:02 -0000 1.5 *************** *** 1,5 **** /* Test precision of mpf_class expressions. ! Copyright 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU MP Library. --- 1,5 ---- /* Test precision of mpf_class expressions. ! Copyright 2001, 2002, 2003, 2008 Free Software Foundation, Inc. This file is part of the GNU MP Library. *************** check_mpf (void) *** 62,66 **** ASSERT_ALWAYS_PREC (g, "0.11111 11111 11111 11111 11111 11111 11111 11111 11111 11111" ! " 11111 11111 11111 11111 11111 11", very_large_prec); } { --- 62,66 ---- ASSERT_ALWAYS_PREC (g, "0.11111 11111 11111 11111 11111 11111 11111 11111 11111 11111" ! " 11111 11111 11111 11111 11111 111", very_large_prec); } { *************** check_mpf (void) *** 70,74 **** ASSERT_ALWAYS_PREC (g, "0.06666 66666 66666 66666 66666 66666 66666 66666 66666 66666" ! " 66666 66666 66666 66666 66666 67", very_large_prec); } --- 70,74 ---- ASSERT_ALWAYS_PREC (g, "0.06666 66666 66666 66666 66666 66666 66666 66666 66666 66666" ! " 66666 66666 66666 66666 66666 667", very_large_prec); } *************** check_mpf (void) *** 95,99 **** ASSERT_ALWAYS_PREC (i, "15.33333 33333 33333 33333 33333 33333 33333 33333 33333 33333" ! " 33333 33333 33333 333", very_large_prec); } { --- 95,99 ---- ASSERT_ALWAYS_PREC (i, "15.33333 33333 33333 33333 33333 33333 33333 33333 33333 33333" ! " 33333 33333 33333 33333 33333 3", very_large_prec); } { *************** check_mpf (void) *** 102,106 **** ASSERT_ALWAYS_PREC (g, "-1.33333 33333 33333 33333 33333 33333 33333 33333 33333 33333" ! " 33333 33333 33333 333", very_large_prec); } { --- 102,106 ---- ASSERT_ALWAYS_PREC (g, "-1.33333 33333 33333 33333 33333 33333 33333 33333 33333 33333" ! " 33333 33333 33333 33333 33333 33", very_large_prec); } { *************** check_mpf (void) *** 118,122 **** ASSERT_ALWAYS_PREC (g, "1.66666 66666 66666 66666 66666 66666 66666 66666 66666 66666" ! " 66666 66666 66666 667", very_large_prec); } --- 118,122 ---- ASSERT_ALWAYS_PREC (g, "1.66666 66666 66666 66666 66666 66666 66666 66666 66666 66666" ! " 66666 66666 66666 66666 66666 67", very_large_prec); } *************** check_mpf (void) *** 143,147 **** g = mpf_class(1 / f); ASSERT_ALWAYS_PREC ! (g, "0.11111 11111 11111 11111 11111 11111 11111 111", medium_prec); } { --- 143,147 ---- g = mpf_class(1 / f); ASSERT_ALWAYS_PREC ! (g, "0.11111 11111 11111 11111 11111 11111 11111 1111", medium_prec); } { *************** check_mpf (void) *** 151,155 **** ASSERT_ALWAYS_PREC (g, "0.06666 66666 66666 66666 66666 66666 66666 66666 66666 66666" ! " 66666 667", large_prec); } --- 151,155 ---- ASSERT_ALWAYS_PREC (g, "0.06666 66666 66666 66666 66666 66666 66666 66666 66666 66666" ! " 66666 6667", large_prec); } *************** check_mpf (void) *** 159,163 **** h = mpf_class(f / g + 1, large_prec); ASSERT_ALWAYS_PREC ! (h, "1.33333 33333 33333 33333 33333 33333 33333 33333 33333 3333", large_prec); } --- 159,164 ---- h = mpf_class(f / g + 1, large_prec); ASSERT_ALWAYS_PREC ! (h, "1.33333 33333 33333 33333 33333 33333 33333 33333 33333 33333" ! " 33333 333", large_prec); } *************** check_mpf (void) *** 171,175 **** ASSERT_ALWAYS_PREC (g, "2.66666 66666 66666 66666 66666 66666 66666 66666 66666 66666" ! " 66666 66666 66666 667", very_large_prec); } --- 172,176 ---- ASSERT_ALWAYS_PREC (g, "2.66666 66666 66666 66666 66666 66666 66666 66666 66666 66666" ! " 66666 66666 66666 66666 66666 67", very_large_prec); } *************** check_mpf (void) *** 180,184 **** g = mpf_class(f - q, large_prec); ASSERT_ALWAYS_PREC ! (g, "2.66666 66666 66666 66666 66666 66666 66666 66666 66666 6667", large_prec); } --- 181,186 ---- g = mpf_class(f - q, large_prec); ASSERT_ALWAYS_PREC ! (g, "2.66666 66666 66666 66666 66666 66666 66666 66666 66666 66666" ! " 66666 667", large_prec); } *************** check_mpf (void) *** 189,193 **** g = mpf_class(f - q); ASSERT_ALWAYS_PREC ! (g, "2.66666 66666 66666 66666 66666 6667", medium_prec); } { --- 191,195 ---- g = mpf_class(f - q); ASSERT_ALWAYS_PREC ! (g, "2.66666 66666 66666 66666 66666 66666 66666 667", medium_prec); } { *************** check_mpf (void) *** 197,201 **** g = mpf_class(f + q); ASSERT_ALWAYS_PREC ! (g, "15.33333 33333 33333 33333 33333 33333 33333 33333 33333 3333", large_prec); } --- 199,204 ---- g = mpf_class(f + q); ASSERT_ALWAYS_PREC ! (g, "15.33333 33333 33333 33333 33333 33333 33333 33333 33333 33333" ! " 33333 33", large_prec); }