Browse - Programming Tips - How can I quickly convert a an ASCII hex number into an integer?

Date: 2010nov25
Language: C/C++
Keywords: fast, speed, integer, hex, hexadecimal

Q.  How can I quickly convert a an ASCII hex number into an integer?

A.

// To convert a 1 digit hexadecimal ASCII number into an integer inline int xtoi(const char c) { if (isdigit(c)) { return c - '0'; } else { return tolower(c) - 'a' + 10; } }