summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authornijtmans <nijtmans>2010-02-22 23:19:16 (GMT)
committernijtmans <nijtmans>2010-02-22 23:19:16 (GMT)
commitbf3967bd2ef27474befb6257b15322b9a9fa7333 (patch)
tree7a38a9dfca27a0ed05c6e880898461aaed4c6161 /generic
parentd58785661f5df34462a865083b64842790ac0263 (diff)
downloadtcl-bf3967bd2ef27474befb6257b15322b9a9fa7333.zip
tcl-bf3967bd2ef27474befb6257b15322b9a9fa7333.tar.gz
tcl-bf3967bd2ef27474befb6257b15322b9a9fa7333.tar.bz2
Fix [Bug 2954959] expr abs(-0.0) is -0.0
Added some test cases, adapted and backported from 8.5
Diffstat (limited to 'generic')
-rw-r--r--generic/tclExecute.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 78e823a..401f485 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclExecute.c,v 1.94.2.30 2009/08/25 20:59:11 andreas_kupries Exp $
+ * RCS: @(#) $Id: tclExecute.c,v 1.94.2.31 2010/02/22 23:19:17 nijtmans Exp $
*/
#include "tclInt.h"
@@ -5374,6 +5374,16 @@ ExprAbsFunc(interp, eePtr, clientData)
d = valuePtr->internalRep.doubleValue;
if (d < 0.0) {
dResult = -d;
+ } else if (d == -0.0) {
+ /* We need to distinguish here between positive 0.0 and
+ * negative -0.0, see Bug ID #2954959.
+ */
+ static const double poszero = 0.0;
+ if (memcmp(&d, &poszero, sizeof(double))) {
+ dResult = -d;
+ } else {
+ dResult = d;
+ }
} else {
dResult = d;
}