Handling of floating point numbers changed from GMP 4.1.4 to GMP 4.2.1
Vincent Lefevre
vincent at vinc17.org
Wed Sep 12 16:55:04 CEST 2007
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.
--
Vincent Lefèvre <vincent at vinc17.org> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)
More information about the gmp-discuss
mailing list