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

Hans Aberg haberg-1 at
Thu Jan 29 10:24:07 UTC 2015

> On 29 Jan 2015, at 11:07, Torbjörn Granlund <tg at> wrote:
> Hans Aberg <haberg-1 at> writes:
>> 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.
> GMP doesn;t use the FPU for the assignment operations from IEEE floats,
> so while the reasoning above might be interesting, it is not relevant in
> the context of the question posed.

I think the OP wants to create such a type, dynamically and automatically switching from IEEE to GMP floating point numbers, but because of time consuming checks, the gain may not be worth the effort. The FPU may generate overflow exceptions, but from what I am told, there is no good way to capture them.

More information about the gmp-discuss mailing list