From c0be36eea23785803ed02370809650be334925f1 Mon Sep 17 00:00:00 2001 From: Louis Rubet Date: Thu, 25 May 2017 22:13:19 +0200 Subject: [PATCH] #66: debugged max precision --- src/rpn-general.hpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/rpn-general.hpp b/src/rpn-general.hpp index b6c21a8..200b349 100644 --- a/src/rpn-general.hpp +++ b/src/rpn-general.hpp @@ -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);