Книга: Introduction to Microprocessors and Microcontrollers

Converting denary to hex

Converting denary to hex

The process follows the same pattern as we saw in the denary to binary conversion.

Method

1 Write down the denary number.

2 Divide it by 1610, put the whole number part of the answer underneath and the remainder in the column to the right.

3 Keep going until the number being divided reaches zero.

4 Read the answer from the bottom to top of the remainders column.

REMEMBER TO WRITE THE REMAINDERS IN HEX.

A worked example

Convert the denary number 23 823 to hex

1 Write down the number to be converted

23 823

(OK so far).

2 Divide by 16. You will need a calculator. The answer is 1488.9375. The 1488 can be placed under the number being converted

23 823

1488

but there is the problem of the decimal part. It is 0.9375 and this is actually 0.9375 of 16. Multiply 0.9375 by 16 and the result is 15. Remember that this 15 needs to be written as a hex number – in this case F. When completed, this step looks like:

23 823

1488 F

3 Repeat the process by dividing the 1488 by 16 to give 93.0 There is no remainder so we can just enter the result as 93 with a zero in the remainder column.

23 823

1488 F

93 0

4 And once again, 93 divided by 16 is 5.8125. We enter the 5 under the 93 and then multiply the 0.8125 by 16 to give 13 or D in hex

23 823

1488 F

93 0

5 D

5 This one is easy. Divide the 5 by 16 to get 0.3125. The answer has now reached zero and 0.3125?16=5. Enter the values in the normal columns to give:

23 823

1488 F = 5D0F

93 0 ?

5 D ?

0 5

6 Read the hex number from the bottom upwards: 5D0FH (remember that the ‘H’ just means a hex number).

Example

Convert 44 25610 into hex

44 256

2766 0 = ACE0H

172 E ?

10 C

0 A

A further example

Convert 540 70910 to hex

540 709

33 794 5 = 84025H

2112 2 ?

132 0

8 4

0 8

So 540 70910=84025H but, especially when the hex number does not contain any letters, be careful to include the base of the numbers otherwise life can become really confusing.

Оглавление книги


Генерация: 1.197. Запросов К БД/Cache: 3 / 0
поделиться
Вверх Вниз