GCSE Computing Revision – Converting to and from Binary Numbers and Understanding Binary

The Concept

  • Computers communicate in binary or machine code
  • This is because they are electronic devices which can only tell the difference between On (electric current flowing) and Off (no current flowing through that bit)
  • A classic programming joke that my teacher once began a lesson by saying is:
  • “There are only 10 types of people in the world: Those who understand binary and those that don’t.”
  • You should get it if you’ve already learnt it for GCSE Computing (this is supposed to be revision not teaching).  If not, you need a reminder:

Understanding Binary

  • What binary is, in mathematical terms is the base two counting system
  • This compares to the ‘normal’ counting system we use, which is called Denary and is base ten
  • If you understand how to count in binary, you DON’T need to read on. This is just so you understand how binary works, but it may be confusing (I was confused whilst writing it!) Skip to the next underlined text if you don’t want to bother reading it.
  • That means that we have 10 different symbols to represent numbers (0, 1, 2, 3, 4, 5, 6, 7, 8 and 9)
  • Whereas binary has only 2 (1 and 0)
  • Because in denary we have just ten symbols they have to be combined to represent numbers higher than 9
  • We do this by adding another digit. Twelve is represented by ’12’, the symbols 1 and 2 together
  • So in base ten we go through ten symbols before adding another digit
  • In base two we go through two symbols before adding another digit
  • I will demonstrate by counting:
  • (Increment means ‘increase by one’)
Denary Binary
0000 //Nothing 0000 //Nothing
0001 //One 0001 //One
0002 //More symbols are available so increment the last digit 0010 //The last digit cannot be incremented because it goes straight to zero. Go to two digits.
0003 //Still more symbols available 0011 //Can increment the last digit
0004 //Keep incrementing the last digit 0100 //First and second digits can’t be incremented so go to three digits
0005 //etc. 0101 //First digit can be incremented
0006 0110 //First digit can’t be incremented so increment the second digit
0007 0111 //First digit can be incremented
0008 1000 //First second and third digits can’t be incremented so go to four digits
0009 //Use up the last number symbol 1001 //First digit can be incremented
0010 //First digit can’t be incremented so go to two digits 1010 //First digit can be incremented so increment the second digit

So to count in binary you:

  • If the number on the right is a 0, make it a 1
  • But if it is already a 1, make it a 0 then…
  • If the number on its left is a zero, make it a 1
  • But if it is already a 1, make it a 0 then…
    If the number on its left is a zero, make it a 1
  • That was just for if you don’t understand how to count up one-at a time in binary
  • You only really need to be able to convert denary to binary and back, not count

Converting from Binary (With examples)

  • You can use a table to convert binary numbers to denary (normal)
  • Since binary is base 2, each digit represents twice the amount of the digit on its right. (If you’ve ever had a maths lesson on place value you’ll know that in normal base 10 each digit represents ten times the digit on its right)
  • The right-most digit is 1 then they double going left
  • This makes a table like this:
128 64 32 16 8 4 2 1
Write your binary digits in these spaces here
  • Then you just write in the digits from the binary number you need to convert
  • It will probably be 8 bit (eight digits long) but if it isn’t, just fill it in backwards from the right
  • Let’s convert 01001011
  • Put it into the table:
128 64 32 16 8 4 2 1
0 1 0 0 1 0 1 1
  • Now it’s as simple as adding together the values with a 1 under them!
  • 64 + 8 + 2 + 1 = 75
  • What a nice result for a binary number I just plucked out of the air… now for another one…
  • Let’s convert 11010101
128 64 32 16 8 4 2 1
1 1 0 1 0 1 0 1
  • 128 + 64 + 16 + 4 + 1 = 213
  • Not such a nice number, but that’s not the point
  • If you haven’t already, try converting 11111111 (that’s eight 1s)

Bits

  • A bit is a binary digit
  • The more bits used to represent a number in binary, the larger the numbers that can be represented
  • 8 bit binary numbers go up to 255 (that’s 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1, the answer to the last question)
  • If you added another bit then the table would be nine columns wide and would go 256 128 64 32 16 8 4 2 1
  • You could represent numbers up to 511

Converting to Binary (Sorry if you hate examples)

  • To convert a denary (normal, base 10) number to binary you just have to do the same thing in reverse
  • Let’s convert 96 to binary.
  • Draw the table leaving the bottom row empty:
128 64 32 16 8 4 2 1
  • Now you think How can I combine these numbers to make 96?”
  • Sometimes it will be obvious, other times you’ll have to work it out
  • To work it out, find the highest number in the list that goes into 96
  • It is of course, 64
  • Put a 1 underneath 64
  • Subtract 64 from 96 to find out what you still need to add
  • 32 still needs to be accounted for
  • What’s the highest number in the table that goes into 32?
  • It’s 32 itself, with nothing left over!
  • Put a 1 under 32 and a 0 under everything else:
128 64 32 16 8 4 2 1
0 1 1 0 0 0 0 0
  • The answer is 01100000
  • Okay, maybe it was a crappy example, so here’s another:
  • Let’s convert 231:
  • Highest number that goes into 231 is 128
  • Put a 1 under 128
  • 231 – 128 = 103
  • Highest number that goes into 103 is 64
  • Put a 1 under 64
  • 103 – 64 =  39
  • Highest number that goes into 39 is 32
  • Put a 1 under 32
  • 39 – 32 = 7
  • Highest number that goes into 7 is 4
  • Put a 1 under 4
  • 7 – 4 = 3
  • Highest number that goes into 3 is 2
  • Put a 1 under 2
  • 3 – 2 = difficult to work out 1
  • Highest number that goes into 1 is 1
  • Put a 1 under 1
  • 1 – 1 = 0
  • Woop! Finished!
128 64 32 16 8 4 2 1
1 1 1 0 0 1 1 1
  • So it was 11100111 all along. That’s a palindrome (same forwards as backwards) and once again, I chose the number completely randomly
  • You knew the last digit had to be ‘ticked’ with a 1 under it because it’s the only way to make an odd number

And that joke?

  • Do you get the joke yet?
  • (Well done to those who already knew the joke or worked it out very quickly)
  • If not, here’s a clue:
  • 10 is not necessarily in denary
  • Try converting 10 from binary to denary then putting it back in the joke at the beginning of the post
Advertisements

About Matt

I like writing, filmmaking, programming and gaming, and prefer creating media to consuming it. On the topic of consumption, I'm also a big fan of eating.
This entry was posted in GCSE Computing Revision and tagged , , , , , , , , . Bookmark the permalink.

2 Responses to GCSE Computing Revision – Converting to and from Binary Numbers and Understanding Binary

  1. Pingback: GCSE Computing Revision – Compression | Matt's blog

  2. Pingback: GCSE Computing Revision – Binary Image Representation | Matt's blog

Enter comment:

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s