Created
September 11, 2013 18:13
-
-
Save henix/6527523 to your computer and use it in GitHub Desktop.
putllong
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static inline void putllong(long long n) | |
{ | |
static char buf[20]; | |
register int pos; | |
register long long x = n; | |
if (x == 0) { | |
putchar('0'); | |
return; | |
} | |
if (x == LLONG_MIN) { // x = -x do not work for the minimal value of long long, so process it first | |
printf("%lld", x); | |
} | |
if (x < 0) { | |
putchar('-'); | |
x = -x; | |
} | |
pos = 0; | |
while (x > 0) { | |
buf[pos] = x % 10 + '0'; | |
x /= 10; | |
pos++; | |
} | |
pos--; | |
while (pos >= 0) { | |
putchar(buf[pos]); | |
pos--; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment