aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2013-03-28 08:41:23 +1000
committerSteve Bennett <steveb@workware.net.au>2013-03-28 08:44:46 +1000
commit2c1eba991e21a6f0b531fb0f83e21f9e6ee7c515 (patch)
tree99c04c85ef678db3e2b8131641df21149b4d05aa
parent738b8b93eec3ffcac1b84ddd85179a4351bc82ef (diff)
downloadjimtcl-2c1eba991e21a6f0b531fb0f83e21f9e6ee7c515.zip
jimtcl-2c1eba991e21a6f0b531fb0f83e21f9e6ee7c515.tar.gz
jimtcl-2c1eba991e21a6f0b531fb0f83e21f9e6ee7c515.tar.bz2
Properly handle systems where (-ve % +ve) returns +ve
Can't just use abs() This is the correct fix rather than c7e5c48 Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r--jim.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/jim.c b/jim.c
index a82b2e4..b2d5853 100644
--- a/jim.c
+++ b/jim.c
@@ -427,7 +427,9 @@ static int JimWideToString(char *buf, jim_wide wideValue)
if (wideValue < 0) {
buf[pos++] = '-';
- tmp[num++] = abs(wideValue % 10);
+ /* -106 % 10 may be -6 or 4! */
+ i = wideValue % 10;
+ tmp[num++] = (i > 0) ? (10 - i) : -i;
wideValue /= -10;
}