Design and Technology
My Own Personal Yellow Brick Road
Slight Detour… into Binary Code
Categories: Explorations

So what is binary? To date my only contact with binary code has been to understand this joke, I know it’s all about a 2 digit system consisting of 1s and 0s and that the binary digit for 2 is 10 (confused yet? ask me to go further than 2 in binary and I will be…) In this section I want to explore binary further to understand how the numbers are formed, how do the 1s and 0s work together…

Binary is a just number system, the only reason it seems so daunting at first glance is because we learn a different number system early in life. The decimal system (or denary/base 10) is like our native language, we are taught it from the moment we are old enough to understand numbers. In the decimal system if you want to express a number greater than 9 you need to use more than 1 digit. Each position in this system represents a power of 10 (100, 101,102, 103, the little number (exponent) tells you how many times to multiple 10 e.g 103 is 10 x10 x10 or 1000) the value of the digit in that position (0-9) is a multiplier for that power of 10, for example look at the table below:

103 (1000s) 102 (100s) 101 (10s) 100 (1s)
9 2 3 0

The table indicates that the number is made up of 0 units, 3 tens, 2 hundreds and 9 thousands or (in a much more concise form) 9000+200+30=9,230. The binary system works in exactly the same way, it just uses a base of 2, learning how to use it is just like learning another language. The binary table headings would look the same just repacing each 10 with a 2:

23 (8s) 22 (4s) 21 (2s) 20 (1s)  
0 0 0 0 0   (0+0+0+0)
0 0 0 1 1   (0+0+0+1)
0 0 1 0 2   (0+0+2+0)
0 0 1 1 3   (0+0+2+1)
0 1 0 0 4   (0+4+0+0)
0 1 0 1 5   (0+4+0+1)
0 1 1 0 6   (0+4+2+0)
0 1 1 1 7   (0+4+2+1)
1 0 0 0 8   (8+0+0+0)

So a 5 is written as 101 or 1 lot of 4s, 0 lost of 2s and 1 lot of 1s, easy when you know how :)

Note (09/03/11) – Look at the patterns! during the taught session with Dean we went through binary code and he asked us to look for patterns,check out the vertical pattern in each column. The ones column goes 01010101, the 2s 001100110011, the 4s 00001111 etc, each column makes a pattern corresponding to its position!

Couple of technical terms for you; the bit on the far right side (in the 1s column ) is called the least significant bit or the LSB and the bit on the far left (in this case the 8s) is the most significant bit or MSB.

It can get a little confusing when you try and add up binary digits, the list below looks fine till you get down to 1+1, any small child can tell you that 1+1=2 so when you’re confronted with 1+1=10 and it’s still correct it can throw you a little…

0 + 0 = 0
1 + 0 = 1
0 + 1 = 1
1 + 1 = 10
1 + 1 + 1 = 11

You’ve just got to remember that the answers are in binary and the 1s and 0s are place values, 1+1=10 = 1 lot of 2s and 0 lots of 1s.

Computers use the binary system to make calculations because the digital circuits inside computers can work easily with bits which are just high and low voltages, This works just as easily for letters as numbers. When you send an email to a friend that says something like ‘binary is awesome!’ (I have actually done that in the last few days…) it doesn’t just magically appear on your mate’s screen. It gets sent through your Internet connection as a series of 1s and 0s, your mate’s computer then interprets these into the words ‘binary is awesome!’.

The actual string for this would be…

01000010 01101001 01101110 01100001 01110010 01111001 00100000 01101001 01110011 00100000 01100001 01110111 01100101 01110011 01101111 01101101 01100101 00100001

Ok, going back to numbers, I get the drift. If you want to work out what number 1101 is you just go (1 x 23)+(1 x 22)+(0 x 22)+(1 x 20) = (1 x 8)+(1 x 4) + (0 x 2)+(1 x 1) = 8+4+0+1 = 13

Note (09/03/11) – another bit to add from the taught session with Dean, two more ways to calculate binary numbers.

Rather than sit and write out the calculations for the various 2ns you just need to get to know the column headings. So to work out the what the decimal equivalent of 01101011 is you just need to write in the position numbers:

128         64           32           16           8              4              2              Units

0              1              1              0              1              0              1              1

 64 + 32 + 8 + 2 + 1 = 107

128         64           32           16           8              4              2              Units

1              0              0              1              0              1              1              1

128 + 16 + 4 + 2 + 1 = 151

Each column heading is just a double of the one before it. See, simples :)

What if you need to work the backwards? Go from a decimal number to a binary one? It’s a lot simpler than you’d first think. You take your decimal number and work out the biggest column number that will fir into it:

234 – largest positional number is 128 (the next in the list is 252)

so there will be a 1 in the end column 

128         64           32           16           8              4              2              Units

1              0              0              0             0              0              0              0

You then take the 128 away from your starting figure: 234- 128 = 106, you keep doing this down the line till you complete your number: 106 – 64 = 42, 42- 32 = 10 at this point you can’t take a 16 away so you move on to the next column and put a 0 here, 10 – 8 = 2, add in a 0 for the 4s, 2 – 2 = 0 and one last 0 for the units.

128         64           32           16           8              4              2              Units

1              1              1              0             1              0              1              0

There is another method you can use but Dean recommended that I shouldn’t use this apart from to check my numbers as I’m not sure why it works…

You add up all you column headings starting with the largest that will fit into the number you are converting:

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

Take your number away from the result:

255 – 234 = 21

Convert the result into binary:

128         64           32           16           8              4              2              Units

0              0              0              1             0              1              0              1

And invert it:

128         64           32           16           8              4              2              Units

1              1              1              0             1              0              1              0

It’s a bit like number alchemy…

Cool, I now have a good understanding of binary, time to move on back to those incredible little logic gates and how they’re made and what they’re made of.

Tags:

Leave a Reply

You must be logged in to post a comment.