Binary Conversion

In this session you will

Revise what binary is

Learn how to convert denary numbers into binary

Be able to convert binary numbers into denary

Keywords

Before you start writing binary please revise the following keywords!!
  1. Binary A number system that contains two symbols, 0 and 1. Also known as base 2.
  2. Data Units of information. In computing there can be different data types, including integers, characters and Boolean. Data is often acted on by instructions.
  3. Denary The number system most commonly used by people. It contains 10 unique digits 0 to 9. Also known as decimal or base 10.
  4. Place value The value of the place, or position, of a digit in a number

Getting started: How do we convert denary numbers to binary?

Maths 101

Humans naturally use base 10 (denary) because we’ve got 10 fingers – if we were aliens with 16 fingers, we might count in base 16.  Computers, though, have to use binary (base 2) because all they have is on and off in circuits. 

In denary, we have the symbols 0–9, and each column / place value has a different value (ones/units on the right, tens next to that, hundreds after that, etc.).  Each column’s value is ten times bigger than the previous one (base ten).

In binary, we just have the symbols 0 and 1.  Now the columns have different values, now each column’s value is two times the previous one:

Task 1 Questions:
  1. What are the column values (for a 4 digit/bit value) in denary and binary?
  2. Write down the number two thousand, four hundred and ninety three in decimal, showing the columns that each digit is in.
  3. Write one in binary.
  4. Write two in binary.
  5. Write four in binary.
  6. Write three in binary.
  7. Write fifteen in binary.
  8. Using long addition, add nine plus nine in denary.
  9. Add 0010 and 0011 in binary.

Converting From Binary to Denary

To convert from a binary number to denary:

  1. Write out the base 2 sequence
  2. Insert the binary number
  3. Add up all the values where you have a 1

(Check: if you’ve got a 1 in the 1’s (right-hand) column, your decimal number should be odd, if it’s a 0, it should be even.)

Example: binary 0001 1010 → denary

16+8+2 = 26

Task 2 Questions:

Convert the following numbers from binary to denary.
NB: Show your working, like the example above.

  1. 00000011
  2. 00001111
  3. 00100010
  4. 11001010
  5. 11111111

Converting from Denary to Binary

To convert from a denary number to binary, I imagine it like I’m paying someone using these weird coins of 128 p, 64 p, 32 p, etc. (the base 2 column headings / place values).

  1. Start at the left/biggest (the 128 column)
  2. Will that value fit in my number? Yes = 1, No = 0
  3. If yes, take the value off the number, how much
    left to go? 
  4. Move to next column (now using the new number)
  5. Check by adding up the column place values that
    you’ve got 1’s under.

Example: denary 30 → binary. Which numbers do you need to add together to get 30?

128 = no; 64= no; 32= no; 16 = yes (30-16=14 to go); 8 = yes (14-8=6 to go); 4 = yes (6-4=2 to go); 2 = yes (2-2=0, all done); 1 = no

Check: 16+8+4+2 =30 ü Answer: 0001 1110

Task 3 Questions:

Convert the following numbers from denary to binary. Show working!

  1. 10
  2. 65
  3. 106
  4. 155
  5. 210
  6. 245
Answers

Task 1: 1) 1000, 100, 10, 1 and 8, 4, 2, 1. 2) 2 1000s, 4 100s, 9 10s, 3 1s. 3) 1 4) 10 5) 100 6) 11 7) 18 8) 0101. 

Task 2: 1) 3 2) 15 3) 34 4) 202 5) 255. 

Task 3: 1) 0000 1010 2) 0100 0001 3) 0110 1010 4) 1001 1011 5) 1101 0010 6) 1111 0101