Patrick.Pelissier at loria.fr
Mon Nov 24 10:08:51 CET 2003
On Sat, Nov 22, 2003 at 11:42:04 -0800, Hee Jung Lee wrote:
> thx ilya, i just read your article & found it very interesting.
> thank you for writing it.
> i have an understanding of the fact that floating point
> arithmatic is not exact. i just expected mpf_set_d to at least
> TRY to set my mpf_t number to be as "exact" as possible to
> the precision that i set the mpf_t number to be. in my
> sample code, i set the default precision to be 400 bits.
> that's a lot of significant digits. & what i ended up w/
> is an mpf_t number that's "exact" up to 16 digits, like double
> precision. so.. my question has to do w/ how mpf_set_d
I don't know if you are interesting but this sample code using mpfr, does what you want:
d = 0.897959184;
mpfr_set_str(m, "0.897959184", 10, GMP_RNDN);
mpfr_out_str(stdout, 10, 0, m, GMP_RNDN);
I don't think using mpf[r]_set_d is a good idea.
More information about the gmp-discuss