The way how I create my mpf_class effects the result after a arithmetic operation
Hans Aberg
haberg-1 at telia.com
Wed Jan 28 22:02:19 UTC 2015
> On 28 Jan 2015, at 18:09, H8H <h8h at dev-nu11.de> wrote:
>
> I see that i.e. python has the same behaviour:
That may be the case because they use the GMP, MPFR and MPC libraries! :-)
> But could you tell me some use cases for which it is better to create a
> mpf_class from a double instead of creating it from a string to have a
> higher precision?
In the 1990s, some C/C++ compilers were poor at translating floats at full precision, pi better implemented as say 4*atan(1).
> Has it a better performance? Is it better for lower
> precisions?
Builtin types, i.e., with hardware support, generally are much faster, and for speed, one should avoid overflow checks if possible. Dynamic allocations are generally slow; one may speed up by using static arrays, or a GC.
Also, the FPU may be optimized around the 64-bit double type (at least in the the past), shorter float type computation done by converting back and forth to a double.
- Best to profile to find out where to optimize.
More information about the gmp-discuss
mailing list