mirror of
https://github.com/louisrubet/rpn
synced 2024-11-17 07:47:50 +01:00
#66: debugged max precision
This commit is contained in:
parent
e3dc6db25e
commit
c0be36eea2
1 changed files with 6 additions and 11 deletions
|
@ -53,10 +53,10 @@ void help()
|
||||||
|
|
||||||
// MPFR_PREC_MAX mpfr_prec_t depends on _MPFR_PREC_FORMAT macro (see mpfr.h)
|
// MPFR_PREC_MAX mpfr_prec_t depends on _MPFR_PREC_FORMAT macro (see mpfr.h)
|
||||||
// this could not exceed 63 bits max (0x7FFFFFFFFFFFFFFF)
|
// this could not exceed 63 bits max (0x7FFFFFFFFFFFFFFF)
|
||||||
int64_t prec_min = (int64_t)MPFR_PREC_MIN;
|
double prec_min = (double)MPFR_PREC_MIN;
|
||||||
int64_t prec_max = (int64_t)MPFR_PREC_MAX;
|
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("Current rounding mode is '%s'\n", floating_t::s_mpfr_rnd_str[floating_t::s_mpfr_rnd]);
|
||||||
printf("\n\n");
|
printf("\n\n");
|
||||||
}
|
}
|
||||||
|
@ -154,14 +154,9 @@ void precision()
|
||||||
MIN_ARGUMENTS(1);
|
MIN_ARGUMENTS(1);
|
||||||
ARG_MUST_BE_OF_TYPE(0, cmd_number);
|
ARG_MUST_BE_OF_TYPE(0, cmd_number);
|
||||||
|
|
||||||
// MPFR_PREC_MAX mpfr_prec_t depends on _MPFR_PREC_FORMAT macro (see mpfr.h)
|
//set precision
|
||||||
// this could not exceed 63 bits max (0x7FFFFFFFFFFFFFFF)
|
unsigned long prec = mpfr_get_ui(((number*)_stack->pop_back())->_value.mpfr, floating_t::s_mpfr_rnd);
|
||||||
int64_t prec_min = (int64_t)MPFR_PREC_MIN;
|
if (prec>=(unsigned long)MPFR_PREC_MIN && prec<=(unsigned long)MPFR_PREC_MAX)
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
floating_t::s_mpfr_prec = (mpfr_prec_t)prec;
|
floating_t::s_mpfr_prec = (mpfr_prec_t)prec;
|
||||||
floating_t::s_mpfr_prec_bytes = mpfr_custom_get_size(prec);
|
floating_t::s_mpfr_prec_bytes = mpfr_custom_get_size(prec);
|
||||||
|
|
Loading…
Reference in a new issue