Binary numbers are base2 numbers containing only 1 or 0. This numbering system came years ago when people were inventing the first computers. All information on the computer is written in binary code, such as numbers, images, data, etc. Those numbers are stored in bits(the smallest memory unit in the computer), and they are in transistors. A standard processor has around 5 billion transistors, so the number stored in bits is related to the flow of electricity in them; if it flows, it is 1(True); if not, 0(False). Also, the possible highest number, which can be represented in n bits is defined by the formula 2^n - 1.
Except for binary numbers, we also have other bases such as base8(Octal),base10(Decimal),base16(Hexadecimal) and so on.
If we already know about decimal numbers, as they are our ordinary digits from 0-9, we also have base8, which is from 0-7.
So, what is their logic? Let us consider base10 we can see that we have digits from 0-9, and then comes 10,11,12...Now imagine there are only eight digits from 0-7 when which number will be after 7? The correct answer is 10, then 11,12 and up to 17, then again 20. This means that we consider that no 8 and 9 even existed.
Now, what about base16? Obviously, we don't have 16 digits, they are only 10 (from 0-9) so after 9 we add letters, hence so-called '10' will be A, then B, C up to F, which represents '15'.Mostly, this numbering system is used to identify colors.
Conversions(base2-base10-base8)
To convert a number from one base to the other, we first convert it to base2, because it will be much easier after that step. Consider a decimal number 45 and we have to represent it in base2. As we remember n bits can be 2^n-1 number highest so...
Now we should take number, which is 1 bigger than [5] => 6,so our number is written in 6 bits, so it has 6 digits. So every number in bit has its index(from right to left, starting from 0). These indexes are also powers for number 2,in our case number 2 is two possible outcomes(0 and 1).Like this...
Now we should somehow figure out either in bits should be 1 or 0, to later multiply that numbers by 2 powered of their index, in our case the number is "101101". The proof => 1*2^5+0 + 2^4 + 1*2^3 + 1*2^2+ 0*2^1 + 1*2^0 = 45
To convert it into base8 we should take base2 and divide number for every 3 digits, as 2^3 = 8 so every 3 digits in binary number = 1 digit in octal. If the number of digits of binary number is not divisible by 3, we should add 0 from the left side.
Returning to our number "101101" to convert it in base8 we divide it in 2 parts "101" and "101" and then using the same technique as during conversion of base2 to base10 we multiply each digit to the powers of 2 regarded to index, so in our case we get this...
The last, but not least to convert from base8 to base10 we should multiply digits to 8 powered by their indexes(positions) like this...




Top comments (0)