Created
September 8, 2020 21:23
-
-
Save Sascha-T/e50ae994375c8241b215c27b7f24f9eb to your computer and use it in GitHub Desktop.
hex to int :D
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
int stli(char *c) { | |
int ret = 0; | |
while (*c != 0) { | |
ret = ret << 4; | |
if(*c >= '1' && *c <= '9') { | |
ret += *c - 48; | |
} | |
if(*c >= 'a' && *c <= 'f') { | |
ret += *c - 87; | |
} | |
c++; | |
} | |
return ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment