slash-root

Converting DECIMAL to HEXIDECIMAL and vice versa


Converting a decimal number to its hex representative is relatively easy. I will demonstate one method for each conversion. Hex is referred to as base16, a numeral system that uses 16 symbols. The symbols available to us are: 1-9 and A-F. This can be broken out into the following representations (hex on the left, decimal on the right):

0 = 0
1 = 1
2 = 2
3 = 3
4 = 4
5 = 5
6 = 6
7 = 7
8 = 8
9 = 9
A = 10
B = 11
C = 12
D = 13
E = 14
F = 15

DECIMAL to HEX Example 1


Lets pick a decimal number, 1009.

Divide the number by 16.

1009 / 16 = 63.0625 (disregard everything after the decimal point) = 63

Now times the remainder 0.0625 by 16.

0.0625 * 16 = 1

Note the answer 1.

Now take division result of 63 and divide this by 16.

63 / 16 = 3.9375 (disregard everything after the decimal point) = 3

Now times the remainder 0.9375 by 16.

0.9375 * 16 = 15.

Note the answer 15 (15 = F)

Now take division result of 3 and divide this by 16.

3 / 16 = 0.1875 (disregard everything after the decimal point) = 0

When we hit 0 on the division, we have reached the end of the chain. Record 3 as the final conversion.

The final step is to simply put the remainders and final conversion together:

3F1

Its always worth checking your conversion using an online decimal to hex tool to ensure your answer is correct.

DECIMAL to HEX Example 2


My decimal number is 54.

54 / 16 = 3.375 = 3

0.375 * 16 = 6 (1st number)

3 / 16 = 0.1875 (note the 3 (2nd number) as this is the end of the chain)

DEC 54 = HEX 36

DECIMAL to HEX Example 3


My decimal number is 633.

633 / 16 = 39.5625 = 39

0.5625 * 16 = 9 (1st number)

39 / 16 = 2.4375 = 2

0.4375 * 16 = 7 (2nd number)

2 / 16 = 0.125 = 2 (3rd number)

DEC 633 = HEX 279

DECIMAL to HEX Example 4


My decimal number is 256.

256 / 16 = 16.0

0 * 16 = 0 (1st number)

16 / 16 = 1.0 = 2

0 * 16 = 0 (2nd number)

1 / 16 = 0.0.625 = 1 (3rd number)

DEC 256 = HEX 100

HEX to DECIMAL Example 1


Converting from hex to decimal is again relatively straight forward, a calculator will again come in handy!

Choose a hex number, I will use A7F.

Follow this simple rule, reading the hex numbers from left to right:

A = 10
10 * 16^2 = 2560

7 = 7
7 * 16^1 = 112

F = 15
15 * 16^0 = 15

2560 + 112 + 15 = 2687

HEX A7F = DEC 2687

HEX to DECIMAL Example 2


My hex number is F6F1

F = 15
15 * 16^3 = 61440

6 = 6
6 * 16^2 = 1536

F = 15
15 * 16^1 = 240

1 = 1
1 * 16^0 = 1

61440 + 1536 + 240 + 1 = 63217

HEX F6F1 = DEC 63217

HEX to DECIMAL Example 3


My hex number is F1

F = 15
15 * 16^1 = 240

1 = 1
1 * 16^0 = 1

240 + 1 = 241

HEX F1 = DEC 241

Hopefully that all makes sense, if not ping me an email and I will try to explain further.

Enquiries

[email protected]

Copyright © 2023 - slash-root.com