ICS3U Number Systems

ICS3U Learning Goals

In this ICS3U Grade 11 Computer Science lesson you will be learning how to:

  • Convert numbers between Decimal, Binary, and Hexadecimal

Working with Number Systems in Computer Science

A number system is just a way people have decided to represent numbers.  Certain systems are better at certain tasks then other systems.

You are used to using the Decimal Number System in your everyday life.  

  • The decimal number system has 10 digits (0 – 9)
  • I don’t have a good reason why that system was chosen a long time ago.  Likely due to ease of use, with some people saying its because we have 10 fingers / toes so it makes it easy to count. 
  • Every number we use can be represented by those 10 digits.
  • These are called Base 10 Numbers

With computer systems it is often easier to represent numbers with other types of number systems

You have probably heard of the Binary Number System

  • Binary Numbers use two digits 0 and 1
  • Computers use electronic components that understand on and off states.  So having a 1 represent the on state, and the 0 represent the off state makes a lot of sense
  • These are called Base 2 Numbers

Another number system that is used quite frequently in computer systems is the Hexadecimal Number System

  • Hexadecimal uses 16 digits (0-9,A-F) where the letters represent the decimal equivalents (A=10, B=11, C=12, D=13, E=14, F=15)
  • Although computers prefer binary, its difficult for humans to always communicate and understand long binary numbers. Hexadecimal provides a bit of a compromise.  It’s easy to convert to binary visually.
  • Hexadecimal numbers are used in HTML color codes and MAC addresses for devices on networks and memory address locations. 
  • These are called Base 16 Numbers

Understanding Place Value and Number Systems

To understand how to covert back and forth between different number systems, you need to remember the concept of place value that you learned in elementary school.

For Decimal Numbers:

  • 1’s column, 10’s column, 100’s column, 1000’s column… etc
  • Those exist because
    • the first column is 10 0 = 1
    • the second column is 10 1 = 10
    • the third column is 10 2 = 100
    • the fourth column is 10 3 = 1000
    • etc
  • Now imagine the decimal number 2673 and thinking about place values that number can be represented as
    • (2 x 1000) + (6 x 100) + (7 x 10) + (3 x 1) = 2673
    • (2 x 103 ) + (6 x 102 ) + (7 x 101 ) + (3 x 100 )= 2673
For Binary Numbers: 
 
  • 1’s column, 2’s column, 4’s column, 8’s column… etc
  • Those exist because
    • the first column is 2 0 = 1
    • the second column is 2 1 = 2
    • the third column is 2 2 = 4
    • the fourth column is 2 3 = 8
    • etc
  • Now imagine the binary number 11010 and thinking about place values that number can be represented as
    • (1 x 16)+ (1 x 8) + (0 x 4) + (1 x 2) + (0 x 1) = 26
    • (1 x 24 ) + (1 x 23 ) + (0 x 22 ) + (1 x 21 ) + (0 x 20 ) = 26
  • So the binary number 11010 is equivalent to the decimal number 26
For Hexadecimal Numbers: 
 
  • 1’s column, 16’s column, 256’s column, 4096’s column… etc
  • Those exist because
    • the first column is 16 0 = 1
    • the second column is 16 1 = 16
    • the third column is 16 2 = 256
    • the fourth column is 16 3 = 4096
    • etc
  • Now imagine the hexadecimal number 3BD and thinking about place values that number can be represented as
    • (3 x 256)+ (11 x 16) + (13 x 1)  = 957
    • (3 x 162 ) + (11 x 161 ) + (13 x 16) = 957
  • So the hexadecimal number 3BD is equivalent to the decimal number 957

This strategy can be used to convert numbers in any number system back into their decimal equivalent.

Converting Decimal Numbers to Other Systems

When converting from decimal numbers to any other base, its a simple matter of dividing by the base and looking at remainders.

Example:  Converting the decimal number 97 to binary

  • 97 / 2 = 48 Remainder 1
  • 48 / 2 = 24 Remainder 0
  • 24 / 2 = 12 Remainder 0
  • 12 / 2 = 6 Remainder 0
  • 6 / 2 = 3 Remainder 0
  • 3 / 2 = 1 Remainder 1
  • 1 / 2 = 0 Remainder 1

To get the answer, read the binary number from the bottom upward to the top: 1100001 is the binary conversion

Example:  Converting the decimal number 44 to binary

  • 44 / 2 = 22 Remainder 0
  • 22 / 2 = 11 Remainder 0
  • 11 / 2 = 5 Remainder 1
  • 5 / 2 = 2 Remainder 1
  • 2 / 2 = 1 Remainder 0
  • 1 / 2 = 0 Remainder 1

The binary equivalent is 101100

Example:  Converting the decimal number 943 to hexadecimal

  • 943 / 16 = 58 Remainder 15 (58 x 16 = 928, 943 – 928 = 15)
  • 58 / 16 = 3 Remainder 10 (3 x 16 = 48, 58 – 48 = 10)
  • 3 / 16 = 0 Remainder 3

The hexadecimal equivalent is 3AF (Remember the 10 = A and 15 = F)

Example:  Converting the decimal number 352 to hexadecimal

  • 352 / 16 = 22 Remainder 0
  • 22 / 16 = 1 Remainder 6 (1  x 16 = 16, 22 – 16 = 6)
  • 1 / 16 = 0 Remainder 1

The hexadecimal equivalent is 160

Sometimes it makes sense to indicate what type of number you are looking at.  How can you tell the difference between 160 in decimal and 160 in hexadecimal?  You might see a subscript with the number indicating the base of the number system the number is representing  16010 and 16016

Bits, Bytes and Nibbles for Binary and Hexadecimal

A single digit in the binary system is called a bit.  A collection of 4 bits is called a nibble.  8 bits is called a byte

Binary numbers are typically written in full nibbles because that makes it easy to convert back and forth into hexadecimal.

Since the nibble has 4 bits, it can take the value of 0 to 15 in decimal (which are the digits in a hexadecimal number system)

  • 0000 = 0
  • 0001 = 1
  • 0010 = 2
  • 0011 = 3
  • 0100 = 4
  • 0101 = 5
  • 0110 = 6
  • 0111 = 7
  • 1000 = 8
  • 1001 = 9
  • 1010 = 10 (A)
  • 1011 = 11 (B)
  • 1100 = 12 (C)
  • 1101 = 13 (D)
  • 1110 = 14 (E)
  • 1111 = 15 (F)

If you get used to working in binary, then these 16 numbers are fairly easy to memorize and you will be able to convert back and forth between binary and hexadecimal very easily

Example: Consider the binary number: 0110 1011 1101 (See how its written as nibbles)

  • 0110 = 6
  • 1011 = B
  • 1101 = D

So the hexadecimal equivalent is 6BD

Example: Now consider the hexadecimal number A7F4

  • A = 1010
  • 7 = 0111
  • F = 1111
  • 4 = 0100

So the binary equivalent is 1010 0111 1111 0100

Video Summary

Watch a video of your teacher summarizing the learning content for this section

ICS3U Number Conversion Activity

Make the following conversions.  You can check your answers with this number system calculator

  • Question 1 – Convert 43510 to binary
  • Question 2 – Convert 216010 to binary
  • Question 3 – Convert 742310 to hexadecimal
  • Question 4 – Convert 10110001002 to decimal
  • Question 5 – Convert 0010 1101 0101 10012 to hexadecimal
  • Question 6 – Convert AF3616 to decimal
  • Question 7 – Convert DAB716 to binary
Return to ICS3U1 Main Page