From 469bdc80712dbf9c12562059dc4594620b59a076 Mon Sep 17 00:00:00 2001 From: Ian Jauslin Date: Wed, 7 Oct 2015 12:51:41 +0000 Subject: Support MPFR floats in numkondo Remove '-D' option (error tolerance) in numkondo --- src/rational_int.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/rational_int.c') diff --git a/src/rational_int.c b/src/rational_int.c index ec601a8..7aab561 100644 --- a/src/rational_int.c +++ b/src/rational_int.c @@ -19,6 +19,10 @@ limitations under the License. #include "rational_int.h" #include #include +#include +// define MPFR_USE_VA_LIST to enable the use of mpfr_inits and mpfr_clears +#define MPFR_USE_VA_LIST +#include #include "istring.h" #include "array.h" @@ -135,6 +139,16 @@ long int lcm(long int x,long int y){ double Q_double_value(Q q){ return(1.0*q.numerator/q.denominator); } +// approximate value as mpfr float +int Q_mpfr_value(mpfr_t out, Q q){ + mpfr_t x; + mpfr_init(out); + mpfr_init(x); + mpfr_set_si(x, q.denominator, MPFR_RNDN); + mpfr_si_div(out, q.numerator, x, MPFR_RNDN); + mpfr_clear(x); + return(0); +} // print to string -- cgit v1.2.3-70-g09d2