How Numbers Are Converted into Binary Ones and Zeros
There are many different counting systems in use today. One in common use is for eggs based on 12 or a dozen. There can be a half-dozen eggs, or three dozen, etc. The pound (weight) is another example. It is divided into 16 ounces.
The most common counting system however is the familiar decimal system, based on 10 digits. This is so common we don’t even think about it generally when we use it to balance our checkbook or figure the miles per gallon our car is getting.
Computers are binary
Computers are made of tiny circuits that have many transistor “switches” that can either be on or off. This means the computer can only count in 2’s. Specifically, the only two digits the computer understands are one and zero.
Just as any number can be formed by combining ten digits (0,1,2,3,4,5,6,7,8 & 9) in the decimal system, any number can be formed by combining two digits (0 & 1) in the binary system. Here’s how:
Places and Powers
The number 325 in our familiar decimal system means 3 hundreds, 2 tens (twenty) and 5 ones. The five is in the ones place, the two is in the tens place and the three is in the hundreds place. If the number had another digit to the left of the 3, this digit will signify the number of thousands and would be in the thousands place. Each of these places in a decimal number represents a power of ten.
Powers simply mean the number multiplied by itself. So the third power of ten is 10x10x10.
Bases and Number Systems
The number that the system is based on is called the “base.” In our decimal system the base is 10. In the binary system the base is 2. An important thing to know is that the first digit (on the right) of a number is the base to the power of zero.
Any number to the zero power equals 1, regardless of how large or small that number is. 14323456 to the power of zero is the same as 4 to the power of zero. They both equal simply 1. That’s why the first (right) digit is the “ones” in any counting system… it is the base to the power of zero. In our example (325) the rightmost digit (5) represents 5 ten-to-the-zero-power’s or 5 ones.
Powers of two
So, by knowing the powers of two (the base of the binary system) we can decipher any binary number or convert any decimal number into binary. The powers of two are very simple, they are just two times two the power-number of times. Two to the fifth power is 2x2x2x2x2 = 32.
A simple example of Binary Notation
In binary notation 32 would be 100000. The fifth power digit in a number is the sixth digit from the right because the first (right) digit is the zero power, so there are five digits to the left of the first to get to the fifth power position.
A more complex example of Binary Notation
The binary number 101 is, from left to right,
1 times 2 to the second power
+0 times 2 to the first power
+1 times 2 to the zero power, or
9 in the decimal system.
Other number systems that are commonly used in computer programming are hexadecimal and octal.