aboutsummaryrefslogtreecommitdiffstats
path: root/mpfr.c
diff options
context:
space:
mode:
Diffstat (limited to 'mpfr.c')
-rw-r--r--mpfr.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/mpfr.c b/mpfr.c
index b9208a6b..1c4a2b9b 100644
--- a/mpfr.c
+++ b/mpfr.c
@@ -3,7 +3,8 @@
*/
/*
- * Copyright (C) 2012, 2013, 2015, 2017, the Free Software Foundation, Inc.
+ * Copyright (C) 2012, 2013, 2015, 2017, 2018,
+ * the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@@ -27,6 +28,8 @@
#ifdef HAVE_MPFR
+int MPFR_round_mode = 'N'; // default value
+
#if !defined(MPFR_VERSION_MAJOR) || MPFR_VERSION_MAJOR < 3
typedef mp_exp_t mpfr_exp_t;
#endif
@@ -373,6 +376,7 @@ mpg_format_val(const char *format, int index, NODE *s)
efree(s->stptr);
s->stptr = r->stptr;
s->flags |= STRCUR;
+ s->strndmode = MPFR_round_mode;
freenode(r); /* Do not unref(r)! We want to keep s->stptr == r->stpr. */
free_wstr(s);
return s;
@@ -596,6 +600,7 @@ set_ROUNDMODE()
if (rndm != -1) {
mpfr_set_default_rounding_mode(rndm);
ROUND_MODE = rndm;
+ MPFR_round_mode = n->stptr[0];
} else
warning(_("RNDMODE value `%.*s' is invalid"), (int) n->stlen, n->stptr);
}