"Remember, even in the darkest '0's of life, there's always a '1' waiting to illuminate your path."
Hey there! Welcome to my very first blog post about binary numbers. I am thrilled that you are here! Today, we're about begin an exciting journey into the fascinating realm of binary numbers, where the two most basic symbols —0 and 1— hold the key to unlocking the secrets of the digital world. So, let's get started and decode the computer language, one '0' and one '1' at a time.
If you're not quite sure what binary numbers are all about, no worries! I've got your back. Check out my YouTube video where I introduce the fascinating world of binary numbers. There, you can get a grasp of the base-2 system and the basics. Afterward, come back over here to dive even deeper into binary number representation, including the math operations and exploring other base systems. It's like a two-step dance of digital knowledge!
Here is the link for the YouTube video: https://www.youtube.com/watch?v=M5ATkD-p3oE
In this blog post, I am going to introduce the topic of different number representations and conversions between one another. As you already know how to convert numbers into base 2 from base 10, let’s discuss a single example and then move forward into other numerical systems.
How to calculate the decimal value of base-2 number 1101001.
We start from the rightmost digit and assign a value to each digit, starting from 2^0 and each time adding one to the exponent as we move to the left.
That’s how we get:
1 1 0 1 0 0 1
2^6 2^5 2^4 2^3 2^2 2^1 2^0
Then we multiply each binary digit with its positional value and add all of them together.
2^6 + 2^5 + 0 + 2^3 + 0 + 0 + 2^0 = 64 + 32 + 8 + 1 = 105.
Now that we understand the idea of how to convert base 2 to base 10, we should also be able to represent numbers in other systems, such as base 8.
Let’s discuss again the number 105. How can we convert it to base 8. Well, since to do so for base 2 we needed to divide the number by 2 repeatedly, the same rule can be applied for base 8. We can divide 105 by 8 till we get one, while writing down all the remainders.
105 | 1
13 | 5
1| 1
Just like with binary conversion, we are rewriting the remainders from bottom to top. That's how we get 151. So, the number 105 in decimal system is the same 151 in base-8/octal numbering system.
Did you notice some pattern in the "magnitude" or "greatness" of the number 105 in different number representations? Apparantely, the bigger the base, the smaller is the number in it. So, the magnitude of 105 is greater when it is in base-2 (1101001), the base-8 151 is much smaller, and base-10 representation is the smallest.
In other words, when the same number (105) is represented in different bases, the "greatness" of the number varies. In a higher base, such as base-2 (binary), the number appears to have a larger magnitude because each digit represents a larger power of the base. Conversely, in a lower base, such as base-10 (decimal), the same number appears smaller because each digit represents a smaller power of the base.
Now let's roll to the mathematical operations, more specifically addition and multiplication for the binary numbers. The key point here is to remember that the math rules are exactly the same for all bases, including binary system. For better understanding, we will discuss 2 examples of addition and multiplication.
Assume we are adding 1011 to 1101.
Binary addition is much like decimal addition, but it works in base-2. In binary, there are only two digits: 0 and 1. So, first we write them one under the other for a better visual representation.
In base-2 system, 1+1 is equal to 10, so we write 0 and carry the 1 to the neihbouring bit. And we repeat the simple addition until we reach the leftmost bit. That's when we write the carry in the answer as well, like we do the same in decimal system.
1011
+ 1101
------
11000
The multiplication is also the same for binary numbers. Let's say we are multiplying 101 and 11.
As usual, we write them one upon the other and start our simple multiplication. Note that in binary 1*1 is also 1 and 1*0 is also 0.
101
x 11
-----
101
101
-----
1111
All in all, you can see that multiplication and addition of binary numbers follow the same rules as the decimal numbers do, meaning one can do a lot of calculations with base-2 numbers without any difficulties.
As we come to a close to our exploration of the world of binary numbers, we've learned some really interesting things. We have seen how numbers can shape-shift depending on the base they're in, and more. The surprising part is that addition and multiplication follow the same rules in the binary universe as they do in the decimal world we live in. So, while you go down this numerical universe, bear in mind that binary is more than just a computer language; it's also a handy tool that may help you solve mathematical puzzles. So, keep your curiosity alive, keep experimenting, and let those '0's and '1's light up your learning path!
Top comments (1)
Every developer should know this. Thanks for sharing!