#66: debugged max precision

This commit is contained in:
Louis Rubet 2017-05-25 22:13:19 +02:00
parent a322362422
commit 79f7aa946a

View file

@ -53,10 +53,10 @@ void help()
// MPFR_PREC_MAX mpfr_prec_t depends on _MPFR_PREC_FORMAT macro (see mpfr.h)
// this could not exceed 63 bits max (0x7FFFFFFFFFFFFFFF)
int64_t prec_min = (int64_t)MPFR_PREC_MIN;
int64_t prec_max = (int64_t)MPFR_PREC_MAX;
double prec_min = (double)MPFR_PREC_MIN;
double prec_max = (double)MPFR_PREC_MAX;
printf("Current floating point precision is %d bits (min=%ld bits, max=0x%lx bits)\n", (int)floating_t::s_mpfr_prec, prec_min, prec_max);
printf("Current floating point precision is %d bits (min=%ld bits, max=0x%lx bits)\n", (int)floating_t::s_mpfr_prec, (int64_t)prec_min, (int64_t)prec_max);
printf("Current rounding mode is '%s'\n", floating_t::s_mpfr_rnd_str[floating_t::s_mpfr_rnd]);
printf("\n\n");
}
@ -154,14 +154,9 @@ void precision()
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
// MPFR_PREC_MAX mpfr_prec_t depends on _MPFR_PREC_FORMAT macro (see mpfr.h)
// this could not exceed 63 bits max (0x7FFFFFFFFFFFFFFF)
int64_t prec_min = (int64_t)MPFR_PREC_MIN;
int64_t prec_max = (int64_t)MPFR_PREC_MAX;
//set MPFR float precision
int64_t prec = mpfr_get_si(((number*)_stack->pop_back())->_value.mpfr, floating_t::s_mpfr_rnd);
if (prec >= prec_min && prec <= prec_max)
//set precision
unsigned long prec = mpfr_get_ui(((number*)_stack->pop_back())->_value.mpfr, floating_t::s_mpfr_rnd);
if (prec>=(unsigned long)MPFR_PREC_MIN && prec<=(unsigned long)MPFR_PREC_MAX)
{
floating_t::s_mpfr_prec = (mpfr_prec_t)prec;
floating_t::s_mpfr_prec_bytes = mpfr_custom_get_size(prec);