# CONVERTING FROM DECIMAL TO HEXADECIMAL

From WikiEducator

** Converting from Decimal to Hexadecimal **

**Converting from Decimal to Hexadecimal**

Steps:

- Divide the decimal number by 16. Treat the division as an integer division.
- Write down the remainder (in hexadecimal).
- Divide the result again by 16. Treat the division as an integer division.
- Repeat step 2 and 3 until result is 0.

The hex value is the digit sequence of the remainders from the last to first.

- Note: a remainder in this topic refers to the left over value after performing an integer division.

HEXADECIMAL 0 1 2 3 4 5 6 7 8 9 A B C D E F

DECIMAL 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

**Example 1**

Convert the number 1128 DECIMAL to HEXADECIMAL

**STEP 1 **

- Start by dividing the number by 16.
- 1128 / 16
- In this case, 1128 divided by 16 is 70.5. So the integer division result is 70 (throw out anything after the decimal point).
- 70
- The remainder is (70.5 - 70) multiplied with 16; or (0.5 times 16), which is 8.

** STEP 2**

- Then, divide the result again by 16
- 70 / 16
- (the number 70 on the DIVISION column comes from the previous RESULT).
- In this case, 70/16=4.375. So the integer division result is 4 (throw out anything after the decimal point)
- The remainder is (0.375 multiplied with 16, which is 6.

**STEP 3**

- Repeat. Note here that 4/16=0.25. So the integer division result is 0.
- The remainder is (0.25-0) multiplied with 16, which is 4.

** STEP 4 **

- Stop because the result is already 0 (0 divided by 16 will always be 0)

**STEP 5**

- Well, (468) is the answer. These numbers come from the REMAINDER column values

- Side note: You can get the remainder of a division using the Modulus or % operator. Ie: 1128%16=8.