A Brief Beginner’s Guide to Binary

We all know computers deal in 1s and 0s but it’s not always that clear what binary is and why it’s even used at all instead of good old decimals. Wouldn’t it make more sense to write eleven as just 11 rather than 01011? The binary system was in existence well before its application to computer science and came to us from George Boole via Leibniz who in turn derived it from the I Ching when he was taking a break from devising intricate metaphysical systems.

I thought it might be worth looking at what we talk about when we talk about binary.

Computers on the whole are made up of transistors dealing in two opposing states: ‘on’– 1 or ‘off’ – 0 (that is until Quantum computers move from theory to production, which isn’t far off).  When we get down to it regardless of what we are doing on a computer at the bottom of it all are circuits being switched on or off. The basic units that do this are called bits or binary digits.

The base 2 numerical representation (1 or 0) used in binary is more efficient in the case of computers when we compare it to decimal’s base 10 (0-9) . While it may look as though representing eleven using the two character ’11’ makes more sense, there is a wider range of possible numbers in base 10 than there is in base 2 which only adds to the complexity of possible outcomes.

Think about how we represent numbers in decimal, we have columns for Hundreds, Tens and Ones. The number 256 for example is:

100 10 1
102 101 100
2 5 6

If it was just 56 then nothing would go in the first column:

100 10 1
102 101 100
0 5 6

When we are representing binary we’re not thinking in tens but in 2s (base 2). To represent ‘3’ we would use (  (20) +(21 = 3): 

4 2 1
22 21  20
0 1 1

Can you figure out what 111 would be?

If you got 7 you would be right. Just something to remember – if we see a 1 in the right most column we’re dealing with an odd number.

For larger numbers we’ll need more columns so for 221 we would need 8 with the left most column representing 128.

To calculate we check if 128 goes into 221 which it does so we add a 1 there. We add 128 and 64 and get 192 and see if this fits inside 221, which again it does, so we add a 1 here too.

Next, we add 192(128+64)+32 and we get 224 which is greater than 221 so this gets a 0 so we skip 32 for our next addition and add 192+16 which gives us 208 which fits into 221 so 16 gets a 1.
208+8 = 216 so 8 gets a 1 and 216+4 = 220 so 4 gets a 1.
Since 220+2 exceeds 221 this gets a 0 and 220+1=221 which fits exactly giving this a 1:

128 64  32 16 8 4 2 1
27 26  25 24 22 22 21  20
1 1 0 1 1 1 0 1

The binary representation, then, of 221 is 11011101.

Copying a 100KB text document from one machine to another involves all 800 bits (1 byte = 8 bits) being transferred one bit at a time over a network. It’s often easy to lose sight of the fact that despite the complexity of computer systems whether on phone, server or desktop machine fundamentally we’re still just pushing binary digits around.

Leave a Reply

Your email address will not be published. Required fields are marked *