Converting a string type hex number to a decimal?

Actually there is a problem. It seems to work in below in case 1 but not in case 2:

case 1: