From 22d0439909069a9dcf4f058ee2314bf8dcb643fc Mon Sep 17 00:00:00 2001 From: apb Date: Tue, 28 Aug 2007 15:23:13 +0000 Subject: [PATCH] In setfval(), ensure that arithmetic never yields a negative zero result. Now {echo | awk '{print -1 * 0}'} prints "0" instead of "-0". Fixes PR 36831. Discussed in tech-userlevel. --- dist/nawk/tran.c | 1 + 1 file changed, 1 insertion(+) diff --git a/dist/nawk/tran.c b/dist/nawk/tran.c index 15874f21ed47..9feb0e0265d5 100644 --- a/dist/nawk/tran.c +++ b/dist/nawk/tran.c @@ -285,6 +285,7 @@ Awkfloat setfval(Cell *vp, Awkfloat f) /* set float val of a Cell */ { int fldno; + f += 0.0; /* normalise negative zero to positive zero */ if ((vp->tval & (NUM | STR)) == 0) funnyvar(vp, "assign to"); if (isfld(vp)) {