Created
October 28, 2012 04:28
-
-
Save letoh/3967509 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| void print_num(int n) | |
| { | |
| unsigned char buf[12] = {0}, *p = buf + 10; | |
| char minus = (n < 0); | |
| if(n < 0) n = -n; | |
| while(n) | |
| { | |
| *p-- = '0' + (n % 10); | |
| n /= 10; | |
| } | |
| if(!*++p) *--p = '0'; | |
| if(minus) *--p = '-'; | |
| uart_puts(p); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment