
-------- Original Message -------- Subject: Re: Handling of floating point numbers changed from GMP 4.1.4 to GMP 4.2.1 Date: Wed, 12 Sep 2007 16:55:04 +0200 From: Vincent Lefevre vincent@vinc17.org To: gmp-discuss@swox.com References: 46E7A688.3030305@cs.unipr.it
On 2007-09-12 10:42:48 +0200, Roberto Bagnara wrote:
The results are different depending on whether it is linked to GMP 4.1.4 or with GMP 4.2.1. For example, on my Fedora 7, x86_64 machine where I have GMP 4.1.4 in /usr/lib64 and GMP 4.2.1 in /usr/local/lib, I use the script
g++ -I/usr/local/include -o bug.o -c bug.cc g++ -static -o bug-gmp-4.2.1 bug.o -L/usr/local/lib -lm -lgmpxx -lgmp g++ -static -o bug-gmp-4.1.4 bug.o -L/usr/lib64 -lm -lgmpxx -lgmp ./bug-gmp-4.2.1 ./bug-gmp-4.1.4
This prints
real_coeff = 137171200400403985/1125899906842624 float = 121.83249999999999602 real_coeff = 137171200400403985/1125899906842624 float = 121.83250000000001023
The mismatch does not happen if one does not touch the rounding mode or if one sets it to FE_TONEAREST, FE_TOWARDZERO, FE_DOWNWARD. So, on this example, while GMP 4.1.4 results do not depend on the rounding mode, with GMP 4.2.1 the rounding mode matters.
Were they compiled with the same compiler and the same compile switches? If not, perhaps one uses SSE2 while the other one uses the traditional FPU.