Browse - Programming Tips - How can I quickly convert a hex digit to an int?

Date: 2017apr27
Language: C/C+
Keywords: atoi, hexadecimal

Q.  How can I quickly convert a hex digit to an int?

A.

inline int xtoi(const char c) { if (isdigit(c)) return c - '0'; return tolower(c) - 'a' + 10; }