MPFR: change max/min exponent

81 Views Asked by At

I use MPREAL one-header library as C++11 wrapper for MPREAL library.

I want to work with numbes like 10^−20000000000000=10^(-2*10^13)

But computation ends with 0

Running

const int max_exp = std::numeric_limits<mpreal>::max_exponent10;

which is equals to min_exponent with inverted sign, gives 1073741823

In mpreal.h I found following lines

// Please note, exponent range is not fixed in MPFR
    static const int min_exponent = MPFR_EMIN_DEFAULT;
    static const int max_exponent = MPFR_EMAX_DEFAULT;
    MPREAL_PERMISSIVE_EXPR static const int min_exponent10 = (int) (MPFR_EMIN_DEFAULT * 0.3010299956639811);
    MPREAL_PERMISSIVE_EXPR static const int max_exponent10 = (int) (MPFR_EMAX_DEFAULT * 0.3010299956639811);

The question is: how to change MPFR_EMAX_DEFAULT and MPFR_EMIN_DEFAULT?

1

There are 1 best solutions below

0
Pavel Holoborodko On

You need to call MPFR functions directly to change the default exponent range:

int mpfr_set_emin (mpfr_exp_t exp)
int mpfr_set_emax (mpfr_exp_t exp)