4 int atoi(const char *str)
6 return strtol(str, 0, 10);
9 long atol(const char *str)
11 return strtol(str, 0, 10);
14 long strtol(const char *str, char **endp, int base)
19 while(isspace(*str)) str++;
23 if(str[1] == 'x' || str[1] == 'X') {
35 } else if(*str == '-') {
42 char c = tolower(*str);
46 } else if(c >= 'a' || c <= 'f') {
53 acc = acc * base + val;
61 return sign > 0 ? acc : -acc;
64 void itoa(int val, char *buf, int base)
80 int digit = val % base;
81 *ptr++ = digit < 10 ? (digit + '0') : (digit - 10 + 'a');
97 void utoa(unsigned int val, char *buf, int base)
107 unsigned int digit = val % base;
108 *ptr++ = digit < 10 ? (digit + '0') : (digit - 10 + 'a');