fix printInt for INT_MIN
This commit is contained in:
parent
3ce167123a
commit
9cd70a7046
6
vga.c
6
vga.c
@ -18,11 +18,11 @@ 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;
|
||||||
integer = integer / 10;
|
num[i++] = (digit > 0) ? digit : -digit;
|
||||||
|
integer = integer / 10;
|
||||||
}
|
}
|
||||||
for (k = i - 1; k >= 0; k--) {
|
for (k = i - 1; k >= 0; k--) {
|
||||||
printChar(num[k] + '0', color, bgColor, x++, startY);
|
printChar(num[k] + '0', color, bgColor, x++, startY);
|
||||||
|
Loading…
Reference in New Issue
Block a user