diff options
author | Steve Bennett <steveb@workware.net.au> | 2013-03-28 08:41:23 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2013-03-28 08:44:46 +1000 |
commit | 2c1eba991e21a6f0b531fb0f83e21f9e6ee7c515 (patch) | |
tree | 99c04c85ef678db3e2b8131641df21149b4d05aa | |
parent | 738b8b93eec3ffcac1b84ddd85179a4351bc82ef (diff) | |
download | jimtcl-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.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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; } |