gmp_printf output

piix piix at gmx.net
Thu Oct 19 11:01:56 CEST 2006


Good morning -  i just wrote a little c program: gmpSize.c

       1 #include "/opt/local/include/gmp.h"
       2 #include <stdio.h>
       3
       4 int main()
       5 {
       6    mpf_set_default_prec(16);
       7    int i = 0;
       8
       9    mpf_t var;
      10    mpf_init_set_d(var,0.9);
      11
      12    for (i=0;i<10;i++)
      13    {
      14       mpf_mul(var,var,var);
      15       gmp_printf("value: %.Ff\n",var); 	//	just request  
significant digits
      16    }
      17 }

which just calculates square of a mpf_t. Compilation with  gcc -o  
size gmpSize.c -lgmp -L/opt/local/lib and running size got me  
following output :

mich% ./size
value: 0.810000000000000039968
value: 0.656100000000000064748
value: 0.430467210000000084963
value: 0.185302018885184173147
value: 0.0343368382029251519552
value: 0.0011790184577738601788
value: 0.00000139008452377145171749
value: 0.00000000000193233498322890371505
value: 0.00000000000000000000000373391848741024760171
value:  
0.0000000000000000000000000000000000000000000000139421472706240313777

Although i got no errors while 'make check' these results are clearly  
wrong. Has somebody the same problem or a solution,

thanks a lot,
alex


More information about the gmp-discuss mailing list