summaryrefslogtreecommitdiffstats
path: root/generic/tclExecute.c
diff options
context:
space:
mode:
authornijtmans <nijtmans@noemail.net>2010-02-22 23:19:16 (GMT)
committernijtmans <nijtmans@noemail.net>2010-02-22 23:19:16 (GMT)
commit6e7e2e71710bf33de6e1d4463c3da0bad63d1929 (patch)
tree7a38a9dfca27a0ed05c6e880898461aaed4c6161 /generic/tclExecute.c
parent3f644b8687057b98f64bbce92a8c29d5c758946f (diff)
downloadtcl-6e7e2e71710bf33de6e1d4463c3da0bad63d1929.zip
tcl-6e7e2e71710bf33de6e1d4463c3da0bad63d1929.tar.gz
tcl-6e7e2e71710bf33de6e1d4463c3da0bad63d1929.tar.bz2
Fix [Bug 2954959] expr abs(-0.0) is -0.0
Added some test cases, adapted and backported from 8.5 FossilOrigin-Name: e53bf599fac90e9be58501623b3f46a9a5250b1a
Diffstat (limited to 'generic/tclExecute.c')
-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;
}