I am writing a string parser and the thought occurred to me that there might be some really interesting ways to convert an ASCII hexadecimal character [0-9A-Fa-f]
to it's numeric value.
What are the quickest, shortest, most elegant or most obscure ways to convert [0-9A-Fa-f]
to it's value between 0
and 15
?
Assume, if you like, that the character is a valid hex character.
I have no chance so I'll have a go at the most boring.
( c <= '9' ) ? ( c - '0' ) : ( (c | '\x60') - 'a' + 10 )