Ilya A. Palopezhentsev
iliks at mail.ru
Sat Nov 22 21:18:21 CET 2003
>this is probably a really basic question. but!
>when i use mpf_set_d(), how do i make sure that
>the copy is "exact"? for example, suppose my double
>value is 0.897959184, i want my mpf_t to be
>0.897959184000000000000000000000 and NOT
I guess it's not possible at all. One shouldn't forget that mpf and mpfr are
_floating_point_ numbers and certain real numbers simply can't be
transferred to this format completely unchanged, this is connected with the
limits imposed by the limited precision of the digit grid of the number. I
suppose this is the case, i.e. when you write
double d = 0.897959184;
it ISN'T stored as 0.897959184, but as
(double has only 15-16 valid digits). The rest of digits are _invalid_.
However, they are transferred to mpf number with correct ones as well.
Floating point numbers do influence various subtle errors, read my article
for further information:
There I explain some bottlenecks of using floating point numbers, in popular
By the way, advice to authors of GMP documentation: I feel it could be
useful to stress there that mpf and mpfr numbers aren't _exact_
representations of _real_ numbers, (as well as float and double in C),
because it seems there are people who don't understand it. If you wish, you
could even insert some excerpts from my article or give a link to it.
More information about the gmp-discuss