If the hexadecimal number is a string you could use the index of each character for your math and as you loop over all the characters you can use a switch statement with 16 cases so you never have to...