The problem with the equation may be the number 16. Yes, hexadecimal is base 16, but uses numbers 0 to 15 (decimal) with 10, 11, 12, 13, 14 and 15 being represented by A, B, C, D, E and F. 16 (decimal) is represented by 10 (hex).
Not sure if this solves the problem but it may help.