Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 80dd9b6

Browse files
committed
Subtle change to hex/oct formatting so the largest negative number
does not receive a minus sign.
1 parent 8dc797d commit 80dd9b6

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Objects/intobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ int_oct(v)
725725
long x = v -> ob_ival;
726726
if (x == 0)
727727
strcpy(buf, "0");
728-
else if (x > 0)
728+
else if (-x < 0)
729729
sprintf(buf, "0%lo", x);
730730
else
731731
sprintf(buf, "-0%lo", -x);
@@ -738,7 +738,7 @@ int_hex(v)
738738
{
739739
char buf[20];
740740
long x = v -> ob_ival;
741-
if (x >= 0)
741+
if (-x <= 0)
742742
sprintf(buf, "0x%lx", x);
743743
else
744744
sprintf(buf, "-0x%lx", -x);

0 commit comments

Comments
 (0)