As humans, many of us are naturally used to the decimal number system; as the prefix deci- implies, the decimal number system is one involving tens. We have ten symbols- 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9- which are used in a variety of combinations to express many numbers, both large and small. If we add 1 to 9, it becomes 10. Adding 1 to 99 becomes 100. Once we exceed the tenth symbol, 9, we add another number position on the leftmost side of the number and set it as 1. Each position represents a power of ten. For example, the number 309 essentially says we have three 102s (or three 100s), no 101s (or, no 10s), and nine 100s (or, nine 1s, since 100 is equal to 1). These numbers allow us to do many wondrous things in our world, and, in some ways, help to keep society functioning. Computers- and all of technology- are able to accomplish a multitude of tasks that extend the capabilities of humanity, and, in some ways, also help keep society functioning on its current level. Incredibly, however, computers do not count in decimal. Instead, they use the binary number system.
What is the Binary Number System?
As the prefix bi- implies, the binary number system involves twos, and has two symbols: 0 and 1. So, zero is still 0, and one is still 1, but once we increase past one, the binary system differs greatly from the decimal system. For example:
Two is 10.
Three is 11.
Four is 100.
Five is 101.
Six is 110.
Seven is 111.
Eight is 1000.
Nine is 1001.
Each position in a binary digit represents a power of 2, just like how each position in a decimal digit represented a power of 10. For example, as stated previously, the number seven is 111. This means one 22 (or one 4, since 22 = 4), one 21 (or one 2, since 21 = 2), and one 20 (or one 1, since 20 = 1). Adding these numbers (4 + 2 + 1) produces seven.
This is how the binary number system works, and this is how computers count and store data.
How Computers Use Binary: An Overview
Specifically, computers store these binary numbers, with each individual number called a bit, as a byte. These bytes contain eight bits, meaning that they are numbers that are eight positions long. Computers then keep track of these bytes (often using other bytes, or, in some cases, they use the first few bits of a byte) to determine what data is being stored, transmitted, or displayed. Below is an extremely basic conceptual example of how this works.
Let’s say that a computer can do three actions: print letters on a piece of paper, show an image on the screen, or play a sound through the speakers. It looks for one of the following three codes to tell it what to do:
Print Letters – 01000100
Display Image – 10010110
Play Sound – 10111100
Say the computer reads in 10010110 11001001 11101100 00000111 01110010.
It will look to see what the first byte contains. The first byte is 10010110; this matches the code for display image, so it knows that the rest of the bytes- 11001001 11101100 00000111 01110010- are data regarding the image it wants to show.
Of course, the actual process is a bit more nuanced than the above, but it works along similar lines.
Conversion from Binary to Decimal & Decimal to Binary
Since decimal and binary are both number systems, a number can be converted from one system to another.
Binary to Decimal
First, it is important to note that there are many methods and techniques used to convert from binary to decimal, and this is not the only way.
Say we have the binary number 11101100.
We know that each position in a binary number represents a power of 2. We then want to break up the binary number based on this rule. The rightmost digit of a binary number always represents 20, so we can start by breaking up the binary number on the right and increasing the exponent for each position we move over.
1110110(0*20)
111011(0*21)+(0*20)
11101(1*22)+(0*21)+(0*20)
1110(1*23)+(1*22)+(0*21)+(0*20)
111(0*24)+(1*23)+(1*22)+(0*21)+(0*20)
11(1*25)+(0*24)+(1*23)+(1*22)+(0*21)+(0*20)
1(1*26)+(1*25)+(0*24)+(1*23)+(1*22)+(0*21)+(0*20)
(1*27)+(1*26)+(1*25)+(0*24)+(1*23)+(1*22)+(0*21)+(0*20).
Now, we have our number broken up. Once this has been done, we simply need to multiply the 2’s by their exponents:
(1*128)+(1*64)+(1*32)+(0*16)+(1*8)+(1*4)+(0*2)+(0*1).
Then, we multiply these numbers by either 1 or 0.
(128)+(64)+(32)+(0)+(8)+(4)+(0)+(0).
Dropping the 0s, this becomes
(128)+(64)+(32)+(8)+(4).
Finally, we just need to add all of these numbers up, which will give us
128+64+32+8+4 = 236.
Decimal to Binary
Similar to the above, it’s important to note that there are multiple methods to convert decimal to binary.
Say we have the number 125. We will be repeatedly dividing this number by 2 and making note of the remainder. There is a mathematical operation, called modulus (usually shown as a %), which divides one number by another as much as possible without creating a fraction and returns whatever the remainder is. For example, 5%2=1, since two can go into five twice (5-2=3, 3-2=1, 1 < 2) before it would create a fraction. We will be doing a similar process.
125%2 gives us a remainder of 1; we then subtract 1 from 125 to give us 124, and divide by 2, giving us 62.
62%2 gives us a remainder of 0; we do not subtract anything, and divide 62 by 2, giving us 31.
31%2 gives us a remainder of 1; we then subtract 1 from 31 to give us 30, and divide by 2, giving us 15.
15%2 gives us a remainder of 1; we then subtract 1 from 15 to give us 14, and divide by 2, giving us 7.
7%2 gives us a remainder of 1; we then subtract 1 from 7 to give us 6, and divide by 2, giving us 3.
3%2 gives us a remainder of 1; we then subtract 1 from 3 to give us 2, and divide by 2, giving us 1.
1%2 gives us a remainder of 1; we then subtract 1 from 1 to give us 0, and divide by 2, which still leaves us with 0.
One would assume the next step to be 0%2, but we actually stop just before taking this step. If we were to continue, we would be stuck in a loop of doing 0%2 (since 0%2 = 0, and 0/2 is 0, we would keep performing these two operations forever on 0).
Now, the actual next step is to take all of our remainders and string them together, starting with the last remainder we got (1%2) and ending with our first (125%2). This gives us 1111101, which is our final result.
Binary Arithmetic
Finally, you can perform arithmetic operations, such as addition and multiplication, on binary numbers. The below videos, created by Sal Khan of KhanAcademy, explain these concepts nicely.





Leave a reply to Jason Lawrence Cancel reply