Our number system is based on the number 10: The digits we use range form 0 to 9, a total of 10 digits, and when we run out of those 10 digits, we just add a new one to the front. This makes sense from an evolutionary standpoint because humans have 10 fingers.
But what would happen if we lived in the Simpsons world? They only have 8 fingers! Or maybe our species grew up like the Teenage Mutant Ninja Turtles, who only have 6 fingers! What would our counting system look like then? What if we were just as competent with our toes as we are with our hands, like a chimpanzee? Then we'd have 20 digits with which to count.
When a computer stores data it is using tiny electromechanical or electromagnetic switches that only have two positions: On and off, 1 or 0, true or false, yes or no. This forces a computer to think and do calculations in what we call binary. Everything is represented as numbers that are combinations of 0's and 1's.
- Georges Ifrah The Universal History of Numbers (Wiley, 2000, pp. 21-22)
In mathematics, we have been taught to think of numbers in decimal format: Each digit in a number can have a value from 0 to 9, and once we pass 9, we add a new digit.
As we count, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, we can see this pattern repeat itself. Binary is no different, except that the value of our digits can only be 0 or 1. Thus we have the table seen on the left:
As you can see, there is a pattern that emerges: Every power of 2 starts a new binary digit (1 has 1 digit, 2 has 2 digits, 4 has 3 digits, 8 has 4 digits). This trick can help us to quickly figure out how to convert binary into decimal.
Lets say we have the binary number 11010010 and we want to know what decimal number that represents, well we can think of each digit from right to left as ascending powers of 2, like this:
Using this technique, we can quickly find the value of 01101101 base 2 in decimal:
64 + 32 + 8 + 4 + 1 = 109 base 10
Converting from decimal to binary is a little more tricky, but there are 2 main methods of conversion:
This method goes as follows:
This method goes as follows:
Try for yourself:
Now that we know about binary, why is it a good idea to state which base we are working in? (Hint: Think of the number 101)
See if you can convert the following values between decimal and the stated base: