DEV Community

Cover image for Binary numbers explained by a gen Z representative
Edita Haroyan
Edita Haroyan

Posted on

Binary numbers explained by a gen Z representative

As the procrastinator I am, I tried my best to simplify binary numbers as much as possible, so here we are.
First of all, why do we need binary numbers? Easy! It's the language of computers, and unlike us, computers are stupid. They can't learn other languages, so we need to know theirs to understand how it works.
Let's start! "Binary" can be understood as a couple. We have 1 and 0, where "1" means something and "0" means nothing. And even though we only have two numbers, we can represent any number with them using powers of "2". Here's an example
Let's try to convert 1 0 1 1 to a decimal
1) The first step is counting from right to the left, starting from zero (because why would we want to do it in a normal way, we need to suffer)
1 0 1 1
3 2 1 0
those are going to be the powers of two.
1 0 1 1
2^3 2^2 2^1 2^0
2) Now, we multiply "2"s with the number above them and add the results
1x2^3+0x2^2+1x2^1+1x2^0
3) The last step is simply calculating the result
8+0+2+1=11
Hooray!! We got the answer, 1011 in binary equals 11 in decimal.
Here's another example without explanation
1 0 1 0 1 0
1 0 1 0 1 0
2^5 2^4 2^3 2^2 2^1 2^0
1x2^5+0x2^4+1x2^3+0x2^2+1x2^1+0x2^0
32+0+8+0+2+0=42
101010=42
Now let's do the opposite.
We're gonna convert 35 to a binary number. There are several methods, but I like this one the best, so I'll only explain this (If you think other ways are better and I should include them, you are absolutely welcomed to go and read someone else's work, thank you:D).
1)The first step is writing all powers of 2 in a decreasing order starting from the one that is closest to our number, and that would be
32 16 8 4 2 1
2) Now, starting from the biggest one, we're trying to understand whether it will be a 1 or 0. If we're gonna use the number, we write 1 and distract the number from the original. If not, then we write 0.
32 16 8 4 2 1
32 we will use, so it's a 1. Now we distract it from 35, and we are left with 3. 16 8 4 we won't need because they are bigger than 3, so all of them are 0. 2 and 1 we will use, so those are 1
Now we have this
100011
And if we want to check, we can try to convert it again, which will give us exactly 35
Here's another example
47
32 16 8 4 2 1
1 0 1 1 1 1
47-32=15, 15-8=7, 7-4=3, 3-2=1, 1-1=0

We have 101111

That was conversion. Now let me present another medieval tortu- I mean things we can do with binary numbers. Those are adding, multiplying, substracting and dividing, basically 4th class stuff.
1) Adding
Let's try to add these
1 0 1 1 1 1 0 0
We put them like second graders do. When we add 0 to 1, we get 1, same with 1+0. And obviously, we get 0 when adding two zeros. However, we don't have the number "2" in binary numbers. So when we add 1 to 1, we carry one "1" to the left side and write a 0.
Image description
And we got 10111. From conversion, we know that 1011 equals 11 and 1100 equals 12, so the sum would be 23. And indeed, 10111 is equal to 23.
Another example
Image description

2) Multiplying
1001 1100
Basically, multiplying the first number separately with all the numbers of the second number and then adding. Here's another masterpiece I made in paint

Image description

As you can see we multiply 1001 with numbers of 1100, then add. So we got 1101100. Another way would be just converting from binary to decimal, multiplying and converting back to binary.
Here's another example
Image description

3) Subtraction! Also like the second grader stuff. Substracting 1 from 1 gives 0, so does 0 from 0, and 0 from 1. However, when we need to subtract 1 from 0, we borrow from the left side and write 1.
Let's subtract 101 from 1111

Image description

Here's an example I borrowed from wikihow

Image description
As you can see, we needed to borrow a few times to get to the answer

4)Division. I find the easiest method to divide the decimals and then convert them, so no explanation here.

SENK YU for your attention.

Top comments (0)