Created
April 8, 2015 03:43
-
-
Save Grumblesaur/cf8e4d82f56f7bfc88f8 to your computer and use it in GitHub Desktop.
From a bad code discussion on cplusplus.com
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
char * itoa(int i,unsigned base){ | |
static char s[sizeof(int)*8+2]; | |
char*t=s+sizeof(int)*8; | |
int sgn=i>=0?1:-1; | |
i/=sgn; | |
do*t--="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\ | |
abcdefghijklmnopqrstuvwxyz+/"[i%base];while(i/=base,i>0); | |
if(sgn<0)*t='-'; | |
else++t; | |
return t; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment