ITEC3831

Name: ______

Lab: Decimal, Binary, Hexadecimal Numbering Systems

  1. Basic number conversion table:

Decimal / 15 / 14 / 13 / 12 / 11 / 10 / 9 / 8 / 7 / 6 / 5 / 4 / 3 / 2 / 1 / 0
Hex / F / E / D / C / B / A / 9 / 8 / 7 / 6 / 5 / 4 / 3 / 2 / 1 / 0
Binary / 1111 / 1110 / 1101 / 1100 / 1011 / 1010 / 1001 / 1000 / 111 / 110 / 101 / 100 / 11 / 10 / 1 / 0
  1. Example of Decimal, Binary, Hexadecimal Numbers

… / 3 / 2 / 1 / 0
… / 103=1000 / 102=100 / 101=10 / 100=1
… / 0 / 2 / 2 / 6

Decimal: Base 10

Example: 226

… / 7 / 6 / 5 / 4 / 3 / 2 / 1 / 0
… / 27=128 / 26=64 / 25=32 / 24=16 / 23=8 / 22=4 / 21=2 / 20=1
… / 1 / 1 / 1 / 0 / 0 / 0 / 1 / 0

Binary: Base 2

Example: 11100010

… / 3 / 2 / 1 / 0
… / 163=4096 / 162=256 / 161=16 / 160=1
… / 0 / 0 / E / 2

Hex: Base 16

Example: 0xE2

  1. Going from Binary/ Hexadecimal to Decimal:

… / 7 / 6 / 5 / 4 / 3 / 2 / 1 / 0
… / 27=128 / 26=64 / 25=32 / 24=16 / 23=8 / 22=4 / 21=2 / 20=1
… / 1 / 1 / 1 / 0 / 0 / 0 / 1 / 0

Binary to Decimal:

Example: 11100010

Solution:

=1x27 + 1x26 +1x25 +0x24 +0x23 +0x22 +1x21 +0x20

=1x128 + 1x64 +1x32 +0x16 +0x8 +0x4 +1x2 +0x1

=128+ 64 + 32 + 0 + 0 + 0 + 2 + 0

=226

… / 3 / 2 / 1 / 0
… / 163=4096 / 162=256 / 161=16 / 160=1
… / 0 / 0 / E / 2

Hexadecimal to Decimal:

Example: 0xE2

Solution:

=0x163 + 0x162 +Ex161 +2x160

=0x4096 + 0x256 +14x16 +2x1

=0 + 0 + 224 + 2

=226

  1. Going from Decimal to Binary/ Hexadecimal:

Example:

Decimal: 123 to Binary

Steps:

1. Find the closest 2 to the power of x

2. If (123≥ 27) the 7th position: 1, else: 0123-0x27= 123

… / 7 / 6 / 5 / 4 / 3 / 2 / 1 / 0
… / 27=128 / 26=64 / 25=32 / 24=16 / 23=8 / 22=4 / 21=2 / 20=1
… / 0 / 1 / 1 / 1 / 1 / 0 / 1 / 1

3. If (123≥26) the 6th position: 1, else: 0123– 1x26= 59

4. If (59 ≥25) the 5th position: 1, else: 059 - 1x25 = 27

5. If (27 ≥24) the 4th position: 1, else: 027 - 1x24=11

6. If (11 ≥23) the 3rd position: 1, else: 011 - 1x 23 = 3

7. If (3 ≥22) the 2nd position: 1, else: 03 - 0x 22 = 3

8. If (3 ≥21) the 1st position: 1, else: 03 - 1x 21 = 1

8. If (1 ≥20) the 0th position: 1, else: 01 - 1x 20 = 0

Example:

Decimal: 3257 to Hexadecimal

Steps:

1. Find the closest 16 to the power of x

2. 3257 163, then the 3rd position: 0

3. 3257 ≥162
3257 ÷162= 12.72xxx , so the 2nd position: 0xC

3257 – 12x162 =185

4. 185 161)

185 ÷161= 11.5625 , so the 1st position: 0xB
185 – 11x161 =9

5. 9 ≥20

… / 3 / 2 / 1 / 0
… / 163=4096 / 162=256 / 161=16 / 160=1
… / 0 / C / B / 9

9÷160= 9 , so the 0th position: 0x9
9– 9x160 =0

  1. Going from Binary to Hex and back

Binary to Hex: 11010010

Steps:

1101 / 0010

1. Group digits, from right to left 4digits one group.

2. Convert each group to Hex,
From the Basic number conversion table: 1101 = 0xD; 0010= 0x2

3. The final result: 0xD2

Hex to Binary: 0x3C

Steps:

From the Basic number conversion table:

0x3 = 0011; 0xC= 1100
3. The final result: 00111100

  1. In Class Lab:

1. Take the following decimal numbers and convert them to binary and hexadecimal:

a) 20

Binary: ______Hexadecimal: ______

b) 35

Binary: ______Hexadecimal: ______

c) 127

Binary: ______Hexadecimal: ______

d) 93

Binary: ______Hexadecimal: ______

2. Take the following binary numbers and convert to hex and decimal:

a) 011101

Decimal: ______Hexadecimal: ______

b) 0110

Decimal: ______Hexadecimal: ______

c) 1010101

Decimal: ______Hexadecimal: ______

3. Take the following hex numbers and convert to binary and decimal:

a) 1F

Decimal: ______Binary: ______

b) FE

Decimal: ______Binary: ______

c) A23

Decimal: ______Binary: ______