Update printing in hex format to be more straight-forward
This commit is contained in:
parent
a7bd2c8ae6
commit
b531496f8e
@ -45,26 +45,17 @@ void puti(int i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void putx(unsigned int i) {
|
void putx(unsigned int i) {
|
||||||
unsigned int left = i;
|
int j;
|
||||||
char buf[1 << (sizeof(int)*8) / 16];
|
|
||||||
char *p = buf;
|
|
||||||
|
|
||||||
puts("0x");
|
puts("0x");
|
||||||
if (!i)
|
|
||||||
putc('0');
|
|
||||||
|
|
||||||
while (left) {
|
for (j = 0; j < 8; j++) {
|
||||||
unsigned int remainder = left % 16;
|
unsigned int toprint = (i >> (4*(7-j))) & 0xf;
|
||||||
left /= 16;
|
if (toprint < 10)
|
||||||
if (remainder < 10)
|
putc(('0'-0) + toprint);
|
||||||
*p = ('0'-0) + remainder;
|
|
||||||
else
|
else
|
||||||
*p = ('a'-10) + remainder;
|
putc(('a'-10) + toprint);
|
||||||
p++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (p-- != buf)
|
|
||||||
putc(*p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int print(char *fmt, ...) {
|
int print(char *fmt, ...) {
|
||||||
|
Loading…
Reference in New Issue
Block a user