0.7 / 1.0 ?= 0.52
Hans Aberg
haberg-1 at telia.com
Fri Jun 15 14:31:01 CEST 2012
On 14 Jun 2012, at 20:40, János Kukoda wrote:
> I have a 5.0.4 GMP downloaded, installed from MacPort. I use it with the newest Xcode, updated just now.
>
> gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00)
>
> The division produce a funny bug. What do you think?
>
> mpf_t a;
> mpf_init(a);
> mpf_set_d(a, 0.7);
> mpf_t b;
> mpf_init(b);
> mpf_set_d(b, 1.0);
> mpf_t l;
> mpf_init(l);
>
> gmp_printf ("%.*Ff \n", 5, a); --- 0.70000
> gmp_printf ("%.*Ff \n", 5, b); --- 1.00000
>
> mpf_div(l, a, b);
> gmp_printf ("%.*Ff", 5, l); --- 0.52502
This example works on Mac OS X 10.7.4 with GMP 5.0.4 compiled directly from source, using the llvm-gcc 4.2.1 you indicate, and the example compiled using this compiler, clang 3.1 also from Xcode 4.3.2, and gcc 4.7.0 compiled from source using this llvm-gcc.
Hans
More information about the gmp-bugs
mailing list