hexval.c (268B)
1 /* see LICENSE file for copyright and license details */ 2 #include "../util.h" 3 4 int 5 hexval(int c) 6 { 7 if ('0' <= c && c <= '9') 8 return c - '0'; 9 if ('a' <= c && c <= 'f') 10 return c - 'a' + 10; 11 if ('A' <= c && c <= 'F') 12 return c - 'A' + 10; 13 return -1; 14 }