From: Ralph Corderoy Date: Sat, 29 Jul 2017 14:06:11 +0000 (+0100) Subject: dtimezone(): Explain abs(3) is undefined on INT_MIN. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/4a56a28ac439137ba2b71fcb5952b4e4abd1e2fc?ds=inline;hp=1dd139e04f59bbfa3a310c2776c4bb2e2fdf1fdd dtimezone(): Explain abs(3) is undefined on INT_MIN. That's why a negative int is flipped over into unsigned by assuming two's complement. --- diff --git a/sbr/dtime.c b/sbr/dtime.c index 3a51d87f..b3ca012a 100644 --- a/sbr/dtime.c +++ b/sbr/dtime.c @@ -291,7 +291,7 @@ char *dtimezone(int offset, int flags) unsigned os, hours, mins; pos = offset >= 0; - os = pos ? offset : ~offset + 1; + os = pos ? offset : ~offset + 1; /* abs(3) undefined on INT_MIN. */ hours = os / 60; mins = os % 60;