def unhex(s):
bits = <NUM_LIT:0><EOL>for c in s:<EOL><INDENT>if '<STR_LIT:0>' <= c <= '<STR_LIT>':<EOL><INDENT>i = ord('<STR_LIT:0>')<EOL><DEDENT>elif '<STR_LIT:a>' <= c <= '<STR_LIT:f>':<EOL><INDENT>i = ord('<STR_LIT:a>')-<NUM_LIT:10><EOL><DEDENT>elif '<STR_LIT:A>' <= c <= '<STR_LIT:F>':<EOL><INDENT>i = ord('<STR_LIT:A>')-<NUM_LIT:10><EOL><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT>bits = bits*<NUM_LIT:16> + (ord(c) - i)<EOL><DEDENT>return bits<EOL>
Get the integer value of a hexadecimal number.