help about gmf_t

wy_pl wy_pl at 126.com
Tue Jun 18 10:17:38 CEST 2013


hi,Ciao:
I have set the "precision" to 200,but the result is incorrect.
the result of gmp is 0.543252595155709340699569887244
but the result of Windows'calculator is 0.543252595155709342560553633217
Could you help me why the results are different?
My code is below.
Kind Regards,
Peng 

#include "gmp.h" 
#include "stdio.h"
int main(void)
{
	mpf_t a,b,c;
	double e=3.14;
	double f=5.78;
	
	mpf_set_default_prec(200); 
	
	mpf_init(a);
	mpf_init(b);
	mpf_init(c);

	mpf_set_d(a,e);
	mpf_set_d(b,f);
	mpf_div(c,a,b);

	gmp_printf("A=%.30Ff\n",a);
	gmp_printf("B=%.30Ff\n",b);
	gmp_printf("C=%.30Ff\n",c);

	mpf_clear(a);
	mpf_clear(b);
	mpf_clear(c);
	
	return 0;
}

	


>Ciao,
>
>Il Mar, 18 Giugno 2013 5:03 am, hai scritto:
>> I need have 30 decimal point,but when it use the float division of gmp,the
>
>You need 30 decimal digits. Did you set "precision" to _at_least_ 
>log_2(10)*30 ~= 100 bits?
>
>Look at
>
>http://gmplib.org/manual/Initializing-Floats.html#Initializing-Floats
>
>Regards,
>m
>
>-- 
>http://bodrato.it/papers/
>


        wy_pl
        wy_pl at 126.com
          2013-06-18


More information about the gmp-discuss mailing list