# Binary — The Way Computers Read Numbers

Binary (/ˈbʌɪnəri/) usually refers to something that involves two things. Many people can look at binary code and instantly associate it with computers without a second thought, but what actually is binary?

# What is Binary?

Computers “read” all (or almost all) instructions in binary. Electricity flows through many transistors which can turn a switch on, or have no electricity run through the transistor leaving a switch off. This on/off structure is responsible for the binary nature of modern day computing.

# Counting Systems (Number bases)

If N-1 becomes larger than 9, we substitute the digits with letters. For example in base 16, the count goes 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F. A number in base 16 would be 10AF (which would be 4271 in base 10!).

## Base 10: Our world

This is special because it means that in base 10, no other combination of numbers can have the same value of 7091. This fact is true for all numbers in any base as long as the two numbers you’re comparing are part of the same base.

## Base 2: Binary

There is no other number that you can write in base 2 that will give you the same value as 1101.

In short, binary is one way of representing a unique number. Just as we know 620 is unique in base 10, a number like 1010 is a representation of a unique number in base 2.

# So… How do we turn our numbers into binary (and vice versa)?

## Binary to Decimal

Which can be written as 1×8 + 1×4 +0×2 + 1×1. The final thing we need to do is to add it all up together. (8+4+0+1) = 13.

Therefore our final answer is 1101 = 13 in base 10.

## Decimal to Binary

1. Find the largest power of two that’s smaller than the number
2. Subtract the power of two from the number
3. Rinse and repeat with the remainder until you reach 0

Let’s do this with the number 175. The largest power of 2 that goes into 175 is 128. To test this, we would go through from the bottom. Does 2⁴ go into 175? Yes. Does 2⁵(32) go into 175? Yes… Does 2⁷(128) go into 175? Yes. Does 2⁸(256) go into 175? No. So the largest is 2⁷.

Our next step is to do 175–128 = 47.

Now we repeat the steps

• There is no 2⁶ term
• 47–32 = 15
• There is no 2⁴ term
• 15–8 = 7
• 7–4 = 3
• 3–2 = 1
• 1–1 = 0

So we can say that 175 = 1(2⁷) + 0(2⁶) + 1(2⁵)+ 0(2⁴) + 1(2³) + 1(2²)+1(2¹) + 1(2⁰), which can be written as 10101111.

And that’s about it! Computers use these numbers in all sorts of ways: Representing characters, adding numbers, executing commands, etc. Hopefully you were able to understand what binary is and how it works. Binary is another segment of maths that often gets overlooked as “computer language” and misunderstood by many people.

# Contact me if you have any other questions!📩

If you enjoyed this article, feel free to give me a follow. I plan on writing more articles to explain harder concepts in a simple fashion.