Hey can someone please tell me a easy way of converting decimal number to hexadecimal numbers and vice versa, thanks

## Hexadecimal convertions

### sparky

Posted 05 September 2006 - 02:29 PM

Ok the definitive guide to converting Hexadecimal numbers!

What you need to remember is that hexadecimal uses the following :-

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

Ok, break the number into the four parts A, 9, 0 and B.

Write down the 4 bit binary for these digits - A is 1010 (Since this represents 10), 9 is 1001, 0 is 0000, and B (Since this represents 11) is 1011.

The number A90B (hex) is then 1010 1001 0000 1011 (base 2/ binary).

This is really quite simple, all you do is :-

(10)(16 x 16 x 16) + (1)(16 x 16) + (3)(16) + (11)(1)

= 41275 (Decimal)

41275 / 16 = 2579 r 11 (B in hex)

2579/16 = 161 r 3

161/16 = 10 r 1

10/16 = 0 r 10 (A in hex)

Then simply read the remainders up the way and you get A13B, which is the number in HEX.

Incase anyone else is wanting to know the wonders of converting Hex!

What you need to remember is that hexadecimal uses the following :-

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

Example 1Example 1

*Convert HEX A90B into it's binary equivalent*Ok, break the number into the four parts A, 9, 0 and B.

Write down the 4 bit binary for these digits - A is 1010 (Since this represents 10), 9 is 1001, 0 is 0000, and B (Since this represents 11) is 1011.

The number A90B (hex) is then 1010 1001 0000 1011 (base 2/ binary).

**Example 2***Convert Hex A13B into decimal*This is really quite simple, all you do is :-

(10)(16 x 16 x 16) + (1)(16 x 16) + (3)(16) + (11)(1)

= 41275 (Decimal)

**Example 3***Convert 41275 into HEX.*41275 / 16 = 2579 r 11 (B in hex)

2579/16 = 161 r 3

161/16 = 10 r 1

10/16 = 0 r 10 (A in hex)

Then simply read the remainders up the way and you get A13B, which is the number in HEX.

Incase anyone else is wanting to know the wonders of converting Hex!