How can I read binary numbers?


#1

Question

How can I read binary numbers?

Answer

Binary isn’t how we’re used to reading numbers, so no worries if it doesn’t make sense at first. Like anything, it’ll become more familiar with practice!
First, let’s break down how the base 10 number system works. This is what we use on a daily basis. The number 134 can also be looked at as 1 * 10^2 + 3 * 10^1 + 4 * 10^0, or 100 + 30 + 4.
Starting at 0 for the rightmost index, each index is the exponent of the base, and you multiply that by the number in that index. That’s why we did 4 * 10^0, because 4 is in the 0th index.
We do the same for any base, including binary.
If we have a bit string of 0b1010, we now know what to do to get the decimal number. It’s equivalent to 0 * 2^0 + 1 * 2^1 + 0 * 2^2 + 1 * 2^3, or 8 + 2, which is 10!


FAQ: Learn Python - Introduction to Bitwise Operators - Lesson I0: The Base 2 Number System