From 3a99ef322dafcd2cf833b2a0668436ac120df1b3 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 15 Jan 2015 13:52:08 +0000 Subject: 34280: more widespread use of FORCE_FLOAT. Add the case of variables read for use in arithmetic expressions. --- Src/math.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'Src') diff --git a/Src/math.c b/Src/math.c index db42d0f7c..c047725c5 100644 --- a/Src/math.c +++ b/Src/math.c @@ -336,16 +336,27 @@ enum prec_type { static mnumber getmathparam(struct mathvalue *mptr) { + mnumber result; if (!mptr->pval) { char *s = mptr->lval; mptr->pval = (Value)zhalloc(sizeof(struct value)); if (!getvalue(mptr->pval, &s, 1)) { mptr->pval = NULL; + if (isset(FORCEFLOAT)) { + result.type = MN_FLOAT; + result.u.d = 0.0; + return result; + } return zero_mnumber; } } - return getnumvalue(mptr->pval); + result = getnumvalue(mptr->pval); + if (isset(FORCEFLOAT) && result.type == MN_INTEGER) { + result.type = MN_FLOAT; + result.u.d = (double)result.u.l; + } + return result; } static mnumber -- cgit 1.4.1