# Help Converting hex

hi how i can convert hex terminating with h ex: 23h to an integer number and vice versa?
tanks

The simplest answer is to use a calculator or website that will do the conversion for you. gweimer/utils library has a couple nodes for doing the conversion if you want to use XOD as your calculator; utils-example-hex shows how to use the conversion nodes. If you are new to hexadecimal numbers, each digit can be 0-15. Since we only have number for 0-9, the letters A-F are used to represent digits 10-15, so 0Bh would be 11 decimal.

The manual process to convert from hex to decimal is to take the 1st digit, multiply by 16, then add the 2nd digit. 23h would be (2 x 16) + 3 = 35 decimal. To convert from decimal to hex, determine how many times the decimal number can be evenly divided by 16; this is your first hex digit & the remainder is the 2nd hex digit. The process gets more involved for numbers larger than FFh (255 decimal). In Hexadecimal, each digit is worth 16^n power. 1st digit is 16^0=1, 2nd digit is 16^1=16, 3rd digit is 16^2=256, etc. This is similar to decimal, though most people seldom think about it. In decimal, the 1st digit is worth 10^0=1, 2nd digit is 10^1=10, 3rd digit is 10^2=100, etc. (i.e. units, 10s, 100s, etc.)

If you already know how to convert between decimal and binary, converting between binary and hex is trivial. Each group of 4 binary bits becomes one hex digit. 23h would be 0010 0011, which can then be converted into decimal (32+2+1=35). Reverse the process for decimal>hex conversion (converting from decimal to binary is NOT trivial, especially for larger numbers). In computer-speak, hexadecimal is basically a short-hand way to write binary numbers (and probably the only reason it is ever used…).

If you are using Windows, the calculator has a Programmer function that converts between Hex, Decimal, and so forth:

Great answer [gweimer], Not too many would have gone through such a good answer as you have done. We all thank you for your gracious giving of your time and knowledge.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.