diff options
author | Peter Stephenson <pws@zsh.org> | 2015-01-15 13:52:08 +0000 |
---|---|---|
committer | Peter Stephenson <pws@zsh.org> | 2015-01-15 13:52:40 +0000 |
commit | 3a99ef322dafcd2cf833b2a0668436ac120df1b3 (patch) | |
tree | 1572509835aab319e5f89ed239d12a3d19518a25 /Src | |
parent | c7aa6443907ddd97b6b1e8729ce9c897de0d244c (diff) | |
download | zsh-3a99ef322dafcd2cf833b2a0668436ac120df1b3.tar.gz zsh-3a99ef322dafcd2cf833b2a0668436ac120df1b3.tar.xz zsh-3a99ef322dafcd2cf833b2a0668436ac120df1b3.zip |
34280: more widespread use of FORCE_FLOAT.
Add the case of variables read for use in arithmetic expressions.
Diffstat (limited to 'Src')
-rw-r--r-- | Src/math.c | 13 |
1 files changed, 12 insertions, 1 deletions
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 |