Monday, April 16, 2012

What is Binary [Detailed Explanation]

        

    
We have all heard about the term 'binary' in our curriculum and many other technical theories. Often , you might have come across 32 bit , 64 bit and similar terms. We usually assume a lot of concepts which we might have overheard.  But till date some points still dont connect the picture you have in your mind. Today lets have a simple outlook towards the concept of Binary


What is binary?( The difference between Base 10 and Base 2)

Most of us have grown up in a base 10 world of numbers, by which I mean we have 10 ‘base’ numbers (0-9) from which we derive all other numbers. Once we’ve exhausted those, we move up a unit level – 10’s, 100’s, 1000’s – this form of counting is hammered into our brains from birth. In actual fact, it was only from the Roman period that we started counting in base 10. Before that, base 12 was the easiest, and people used their knuckles to count.
When we learn base 10 in elementary school, we often write out the units like this:
what is binary code
So the number 1990 actually consists of 1 x 10009 x 1009 x 10, and 0 x 1. I’m sure I don’t need to explain base 10 any further than that.
But what if instead of having a full selection of 0,1,2,3,4,5,6,7,8,9 to work with as the base numbers – what if we only had 0, and 1. This is called base 2; and it’s also commonly referred to as binary. In a binary world, you can only count 0,1 – then you need to move to the next unit level.

Counting in Binary

It helps immensely if we write out the units when learning binary. In this case, instead of each additional unit being multiplied by 10, it’s multiplied by 2, giving us 1,2,4,8,16,32,64 … So to help calculate, we can write them out like this:
what is binary
In other words, the right-most value in a binary number represents how many 1’s. The next digit, to the left of that, represent how many 2’s. The next represents how many 4’s… and so.
With that knowledge, we can write out a table of counting in binary, with the equivalent base 10 value indicated on the left.
what is binary code
Spend a moment going over that until you can see exactly why 25 is written as 11001. You should be able to break it down as being 16+8+1 = 25.

Working backwards – base 10 to binary

You should now be able to figure out what value a binary number has by drawing a similar table and multiplying each unit. To switch a regular base 10 number to binary takes a little more effort. The first step is to find the largest binary unit that “fits into” the number. So for example, if we were doing 35, then the largest number from that table that fits into 35 is 32, so we would have a 1 there in that column. We then have a remainder of 3 – which would need a 2, and then finally a 1. So we get 100011.

8-bits, Bytes, and Octets

The table I’ve shown above is 8-bit, because we have a maximum of 8 zeroes and ones to use for our binary number. Thus, the maximum number we can possibly represent is 11111111,  or 255. This is why in order to represent any number from 0-255, we need at least 8-bits. Octet and Byte is simply another way of saying 8-bits. Therefore 1 Byte = 8 bits.

32 vs 64-bit Computing

Nowadays you often hear the terms 32-bit and 64-bit versions of Windows, and you may know that 32-bit Windows can only support up to 4 gigabytes of RAM. Why is that though?
It all comes down to memory addressing. Each bit of memory needs a unique address in order to access it. If we had an 8-bit memory addressing system, we would only be able to have a maximum of 256 bytes of memory. With a 32-bit memory addressing system (imagine extending the table above to have 32 binary unit columns), we can go anywhere up to4,294,967,296 ? 4 billion bytes, or in other words – GIGAbytes. 64-bit computing essentially removes this limit by giving us up to 18 quintillion different addresses – a number most of us simply can’t fathom.

IPv4 Addressing

The latest worry in the computing world is all about IP addresses, in particular IPv4addresses, like these:
  • 192.168.0.1
  • 200.187.54.22
They actually consist of 4 numbers, each representing a value up to 255. Can you guess why? Yep, the whole address is represented by 4 octets (32 bits in total). This seemed like an awful lot of possible addresses (around 4 billion in fact) at the time the internet was first invented, but we’re rapidly running out now that everything in our life needs to be connected. To solve this, the new IPv6 uses 128 bits in total, giving us approximately 340 undecillion(put 38 zeroes on the end) addresses to play with.

0 comments:

Post a Comment