The way how I create my mpf_class effects the result after a arithmetic operation

H8H h8h at dev-nu11.de
Wed Jan 28 23:30:42 UTC 2015


> In the 1990s, some C/C++ compilers were poor at translating floats at
full precision, pi better implemented as say 4*atan(1).

Yep thats right. Better to implemented pi with mpz_t objects.

All i wanna do is to build a switch, so that the user hasn't care about
the floating points and its limitations. If an arithmetic operation ends
in an inf / nan / subnormal or whatever the tool recalc the operation
with the mpf_class / mpf_* object. The user has also the opportunity to
set a precision, therefore the tool should use the mpf_class for the
arithmetic operation directly. Furthermore every object (double or
mpf_class) in the program i've build has its own precision (for doubles
52bits / for mpf_class the default or the one which was set). Thats why
it could happen that if the user want to divide some "short" floating
points and the result should have a very high percision the function
gets two doubles and should output a mpf_class with the set percision.
For this case I have to "transform" these doubles to mpf_classes.

And as I've seen / read it here thanks to your postings this only works
if I "transform" these doubles to strings/char* and after that to
mpf_classes.

Its not that fast, but its the only way to get the right high precision.


More information about the gmp-discuss mailing list