fix printInt for INT_MIN
This commit is contained in:
parent
3ce167123a
commit
9cd70a7046
4
vga.c
4
vga.c
@ -18,10 +18,10 @@ void printInt(int integer, uint color, uint bgColor, int startX, int startY)
|
|||||||
int i = 0, k = 0;
|
int i = 0, k = 0;
|
||||||
if (integer < 0) {
|
if (integer < 0) {
|
||||||
printChar('-', color, bgColor, x++, startY);
|
printChar('-', color, bgColor, x++, startY);
|
||||||
integer = -integer;
|
|
||||||
}
|
}
|
||||||
while (integer != 0) {
|
while (integer != 0) {
|
||||||
num[i++] = integer % 10;
|
int digit = integer % 10;
|
||||||
|
num[i++] = (digit > 0) ? digit : -digit;
|
||||||
integer = integer / 10;
|
integer = integer / 10;
|
||||||
}
|
}
|
||||||
for (k = i - 1; k >= 0; k--) {
|
for (k = i - 1; k >= 0; k--) {
|
||||||
|
Loading…
Reference in New Issue
Block a user