3b Converting Between Number Bases

  • Understand how binary can be used to represent whole numbers.
  • Understand how hexadecimal can be used to represent whole numbers.
  • Be able to convert in both directions between:
    • binary and decimal
    • binary and hexadecimal
    • decimal and hexadecimal

Numbers in Binary

  • Ten digits (fingers)
  • 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
  • After nine, move left a place:
    • 10, 11, 12, ...
  • After ninety-nine, move left a place:
    • 100, 101, ...

Converting Denary to Binary

To convert a denary (decimal) number to a binary number:

  1. Divide by two and write any remainder.
  2. Repeat until the answer is zero with or without a remainder.
  3. Write down the remainders in reverse order.
  4. Add enough zeroes on the left hand side to make the number eight digits.

Converting Denary to Binary

Convert the denary (decimal) number 153 to a binary number.

  1. Divide by two and write any remainder.
  2. Repeat until the answer is zero with or without a remainder.
  3. Write down the remainders in reverse order.
  4. Add enough zeroes on the left hand side to make the number eight digits.

\(1\)

\(0\)

\(0\)

\(0\)

\(1\)

\(1\)

\(0\)

\(1\)

\(153 \div 2 = 76 \ r1\)

\(76 \div 2 = 38 \ r0\)

\(38 \div 2 = 19 \ r0\)

\(19 \div 2 = 9 \ r1\)

\(9 \div 2 = 4 \ r1\)

\(4 \div 2 = 2 \ r0\)

\(2 \div 2 = 1 \ r0\)

\(1 \div 2 = 0 \ r1\)

Converting Denary to Binary

Convert the denary (decimal) number 63 to a binary number.

  1. Divide by two and write any remainder.
  2. Repeat until the answer is zero with or without a remainder.
  3. Write down the remainders in reverse order.
  4. Add enough zeroes on the left hand side to make the number eight digits.

\(63 \div 2 = 31 \ r1\)

\(31 \div 2 = 15 \ r1\)

\(15 \div 2 = 7 \ r1\)

\(7 \div 2 = 3 \ r1\)

\(3 \div 2 = 1 \ r1\)

\(1 \div 2 = 0 \ r1\)

\(1\)

\(1\)

\(1\)

\(1\)

\(1\)

\(1\)

\(0\)

\(0\)

\(1\)

\(1\)

\(1\)

\(1\)

\(1\)

\(1\)

Converting Denary to Binary

Convert these denary numbers to binary numbers.

  1. Divide by two and write any remainder.
  2. Repeat until the answer is zero with or without a remainder.
  3. Write down the remainders in reverse order.
  4. Add enough zeroes on the left hand side to make the number eight digits.
  1. 168
  2. 47
  3. 255
  4. 1
  5. 0

\(1010 \ 1000\)

\(0010 \ 1111\)

\(1111 \ 1111\)

\(0000 \ 0001\)

\(0000 \ 0000\)

Converting Binary to Denary

To convert a number from binary to denary:

  1. Write the number out.
  2. Put the place value above each digit.
  3. Wherever there is a '1' add up the place value.

Converting Binary to Denary

Convert the binary number 0110 1101 to a denary number.

  1. Write the number out.
  2. Put the place value above each digit.
  3. Wherever there is a 1 add up the place value.

128's

64's

32's

4's

16's

8's

2's

1's

64 + 32 + 8 + 4 + 1 = 109

\(0\)

\(1\)

\(1\)

\(1\)

\(0\)

\(1\)

\(0\)

\(1\)

Converting Binary to Denary

Convert the following binary numbers to denary numbers.

  1. Write the number out.
  2. Put the place value above each digit.
  3. Wherever there is a 1 add up the place value.

128 + 32 + 16 + 8 = 184

  1. 1011 1000
  2. 0010 1111
  3. 0000 0100
  4. 1111 1111

32 + 8 + 4 + 2 + 1 = 47

4

128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255

Base Sixteen - Hexadecimal

  • Sixteen digits (represents 4 bits)
  • 0, 1, 2, 3, 4, 5, 6, 7, 
    8, 9, A, B, C, D, E, F
  • A = 10, B = 11, C = 12, 
    D = 13, E = 14, F = 15
  • Usually written as a pair of digits:
  • 00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 0A, 0B, 0C, 0D, 0E, 0F

Converting to Hexadecimal

A = 10

B = 11

C = 12

D = 13

E = 14

F = 15

  1. Convert to 8-bit binary first.
  2. Split into two four-bit segments.
  3. Convert each segment back into denary.
  4. Convert each of the two segments into hexadecimal.

Converting to Hexadecimal

Convert the denary (decimal) number 153 to a hexadecimal number.

  1. Convert to 8-bit binary first.
  2. Split into two four-bit segments.
  3. Convert each segment back into denary.
  4. Convert each of the two segments into hexadecimal.

\(153_{10} = 1001 \ 1001_2\)

\(153_{10} = 99_{16}\)

\(8 + 1 = 9_{10}\)

\(9_{10} = 9_{16}\)

8's

4's

2's

1's

\(1\)

\(0\)

\(0\)

\(1\)

\(8 + 1 = 9_{10}\)

\(9_{10} = 9_{16}\)

8's

4's

2's

\(0\)

1's

\(1\)

\(0\)

\(1\)

Converting to Hexadecimal

Convert the denary (decimal) number 63 to a binary number.

\(63_{10} = 0011 \ 1111_{2}\)

  1. Convert to 8-bit binary first.
  2. Split into two four-bit segments.
  3. Convert each segment back into denary.
  4. Convert each of the two segments into hexadecimal.

\(8 + 4 + 2 + 1 = 15_{10}\)

\(15_{10} = F_{16}\)

8's

4's

2's

1's

\(1\)

\(1\)

\(1\)

\(1\)

\(2 + 1 = 3_{10}\)

\(3_{10} = 3_{16}\)

8's

4's

2's

\(0\)

1's

\(0\)

\(1\)

\(1\)

\(63_{10} = 3F_{16}\)

Converting to Hexadecimal

Convert these denary numbers to hexadecimal numbers.

  1. 168
  2. 47
  3. 255
  4. 1
  5. 0

\(A8\)

\(2F\)

\(FF\)

\(01\)

\(00\)

  1. Convert to 8-bit binary first.
  2. Split into two four-bit segments.
  3. Convert each segment back into denary.
  4. Convert each of the two segments into hexadecimal.

Converting Hexadecimal to Denary

To convert a hexidecimal number to a denary number.

  1. Convert each digit to binary.
  2. Add the place value above each binary digit.
  3. Add the place values for every '1' digit.

Converting Hexadecimal to Denary

Convert the hexadecimal number 6D to a denary number.

128's

64's

32's

4's

16's

8's

2's

1's

64 + 32 + 8 + 4 + 1 = 109

\(0\)

\(1\)

\(1\)

\(1\)

\(0\)

\(1\)

\(0\)

\(1\)

  1. Convert each digit to binary.
  2. Add the place value above each binary digit.
  3. Add the place values for every '1' digit.

616 = 01102

D16 = 11012

6D16 = 0110 11012

Converting Hexadecimal to Denary

Convert the following hexadecimal numbers to denary numbers.

1011 01002 = 18010

  1. Convert each digit to binary.
  2. Add the place value above each binary digit.
  3. Add the place values for every '1' digit.
  1. B4
  2. 3F
  3. FF
  4. 0F

0011 11112 = 6310

1111 11112 = 25510

0000 11112 = 1510

3b Converting Number Bases

By David James

3b Converting Number Bases

Computer Science - Fundamentals of Data Representation - Converting Between Number Bases

  • 383