mpfr precision
afvallen
afvallenrecept at live.com
Wed Oct 24 00:53:18 CEST 2012
Hi,
I am trying to a basic working program with the precision printed out
correctly.
mpfr_t t,x,y;
mpfr_init(t);
mpfr_init(x);
mpfr_init(y);
mpfr_set_str(x,"460.8952",10,MPFR_RNDN);
mpfr_set_str(y,"10.0",10,MPFR_RNDN);
mpfr_mul(t,x,y,MPFR_RNDN);
mpfr_printf("%.32Rf",t);
It prints out: 4608.9520000000002255546803968203.
Obviously its not supposed to be that but just "4608.952" instead.
1. Why is that? Other times with for example abs it will just start to
make up numbers.
2. How can I get sprintf or printed out the right precision if I don't
know how many numbers there will or could be after the dot, instead of
just get 32 zeros printed out? The max being 32 however.
3. Why is the calculated output always different from when I use the
regular OS calculator? It starts to slightly differ the more digits
after the dot.
Thanks.
More information about the gmp-discuss
mailing list