Handling of floating point numbers changed from GMP 4.1.4 to GMP 4.2.1

Roberto Bagnara bagnara at cs.unipr.it
Wed Sep 12 17:14:21 CEST 2007


Vincent Lefevre wrote:
> 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.

Same compiler and same switches as per the script above.

-- 
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:bagnara at cs.unipr.it


More information about the gmp-discuss mailing list