Conversion of binary to decimal (base-2 to base-10) numbers and back is an important concept to understand as the binary numbering system forms the basis for all computer and digital systems.
The decimal or “denary” counting system uses the Base-of-10 numbering system where each digit in a number takes on one of ten possible values, called “digits”, from 0 to 9, eg. 213_{10} (Two Hundred and Thirteen).
But as well as having 10 digits ( 0 through 9 ), the decimal numbering system also has the operations of addition ( + ), subtraction ( – ), multiplication ( × ) and division ( ÷ ).
In a decimal system each digit has a value ten times greater than its previous number and this decimal numbering system uses a set of symbols, b, together with a base, q, to determine the weight of each digit within a number. For example, the six in sixty has a lower weighting than the six in six hundred. Then in a binary numbering system we need some way of converting Decimal to Binary as well as back from Binary to Decimal.
Any numbering system can be summarised by the following relationship:
N = b_{i }q^{i} | |
where: | N is a real positive number b is the digit q is the base value and integer (i) can be positive, negative or zero |
N = b_{n} q^{n}… b_{3} q^{3} + b_{2} q^{2} + b_{1} q^{1} + b_{0} q^{0} + b_{-1} q^{-1} + b_{-2} q^{-2}… etc.
In the decimal, base-10 (den) or denary numbering system, each integer number column has values of units, tens, hundreds, thousands, etc as we move along the number from right to left. Mathematically these values are written as 10^{0}, 10^{1}, 10^{2}, 10^{3} etc. Then each position to the left of the decimal point indicates an increased positive power of 10. Likewise, for fractional numbers the weight of the number becomes more negative as we move from left to right, 10^{-1}, 10^{-2}, 10^{-3} etc.
So we can see that the “decimal numbering system” has a base of 10 or modulo-10 (sometimes called MOD-10) with the position of each digit in the decimal system indicating the magnitude or weight of that digit as q is equal to “10” (0 through 9). For example, 20 (twenty) is the same as saying 2 x 10^{1} and therefore 400 (four hundred) is the same as saying 4 x 10^{2}.
The value of any decimal number will be equal to the sum of its digits multiplied by their respective weights. For example: N = 6163_{10} (Six Thousand One Hundred and Sixty Three) in a decimal format is equal to:
6000 + 100 + 60 + 3 = 6163
or it can be written reflecting the weight of each digit as:
( 6×1000 ) + ( 1×100 ) + ( 6×10 ) + ( 3×1 ) = 6163
or it can be written in polynomial form as:
( 6×10^{3} ) + ( 1×10^{2} ) + ( 6×10^{1} ) + ( 3×10^{0} ) = 6163
Where in this decimal numbering system example, the left most digit is the most significant digit, or MSD, and the right most digit is the least significant digit or LSD. In other words, the digit 6 is the MSD since its left most position carries the most weight, and the number 3 is the LSD as its right most position carries the least weight.
The Binary Numbering System is the most fundamental numbering system in all digital and computer based systems and binary numbers follow the same set of rules as the decimal numbering system. But unlike the decimal system which uses powers of ten, the binary numbering system works on powers of two giving a binary to decimal conversion from base-2 to base-10.
Digital logic and computer systems use just two values or states to represent a condition, a logic level “1” or a logic level “0”, and each “0” and “1” is considered to be a single digit in a Base-of-2 (bi) or “binary numbering system”.
In the binary numbering system, a binary number such as 101100101 is expressed with a string of “1’s” and “0’s” with each digit along the string from right to left having a value twice that of the previous digit. But as it is a binary digit it can only have a value of either “1” or “0” therefore, q is equal to “2” (0 or 1) with its position indicating its weight within the string.
As the decimal number is a weighted number, converting from decimal to binary (base 10 to base 2) will also produce a weighted binary number with the right-hand most bit being the Least Significant Bit or LSB, and the left-hand most bit being the Most Significant Bit or MSB, and we can represent this as:
MSB | Binary Digit | LSB | ||||||
2^{8} | 2^{7} | 2^{6} | 2^{5} | 2^{4} | 2^{3} | 2^{2} | 2^{1} | 2^{0} |
256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
We saw above that in the decimal number system, the weight of each digit to the left increases by a factor of 10. In the binary number system, the weight of each digit increases by a factor of 2 as shown. Then the first digit has a weight of 1 ( 2^{0} ), the second digit has a weight of 2 ( 2^{1} ), the third a weight of 4 ( 2^{2} ), the fourth a weight of 8 ( 2^{3} ) and so on.
So for example, converting a Binary to Decimal number would be:
Decimal Digit Value | 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
Binary Digit Value | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | 1 |
By adding together ALL the decimal number values from right to left at the positions that are represented by a “1” gives us: (256) + (64) + (32) + (4) + (1) = 357_{10} or three hundred and fifty seven as a decimal number.
Then, we can convert binary to decimal by finding the decimal equivalent of the binary array of digits 101100101_{2} and expanding the binary digits into a series with a base of 2 giving an equivalent of 357_{10} in decimal or denary.
We have seen above how to convert binary to decimal numbers, but how do we convert a decimal number into a binary number. An easy method of converting decimal to binary number equivalents is to write down the decimal number and to continually divide-by-2 (two) to give a result and a remainder of either a “1” or a “0” until the final result equals zero.
So for example. Convert the decimal number 294_{10} into its binary number equivalent.
Number | 294 |
Dividing each decimal number by “2” as shown will give a result plus a remainder. If the decimal number being divided is even then the result will be whole and the remainder will be equal to “0”. If the decimal number is odd then the result will not divide completely and the remainder will be a “1”. The binary result is obtained by placing all the remainders in order with the least significant bit (LSB) being at the top and the most significant bit (MSB) being at the bottom. |
||
divide by 2 | ||||
result | 147 | remainder | 0 (LSB) | |
divide by 2 | ||||
result | 73 | remainder | 1 | |
divide by 2 | ||||
result | 36 | remainder | 1 | |
divide by 2 | ||||
result | 18 | remainder | 0 | |
divide by 2 | ||||
result | 9 | remainder | 0 | |
divide by 2 | ||||
result | 4 | remainder | 1 | |
divide by 2 | ||||
result | 2 | remainder | 0 | |
divide by 2 | ||||
result | 1 | remainder | 0 | |
divide by 2 | ||||
result | 0 | remainder | 1 (MSB) |
This divide-by-2 decimal to binary conversion technique gives the decimal number 294_{10} an equivalent of 100100110_{2} in binary, reading from right to left. This divide-by-2 method will also work for conversion to other number bases.
Then we can see that the main characteristics of a Binary Numbering System is that each “binary digit” or “bit” has a value of either “1” or “0” with each bit having a weight or value double that of its previous bit starting from the lowest or least significant bit (LSB) and this is called the “sum-of-weights” method.
So we can convert a decimal number into a binary number either by using the sum-of-weights method or by using the repeated division-by-2 method, and convert binary to decimal by finding its sum-of-weights.
Binary numbers can be added together and subtracted just like decimal numbers with the result being combined into one of several size ranges depending upon the number of bits being used. Binary numbers come in three basic forms – a bit, a byte and a word, where a bit is a single binary digit, a byte is eight binary digits, and a word is 16 binary digits.
The classification of individual bits into larger groups are generally referred to by the following more common names of:
Number of Binary Digits (bits) | Common Name |
1 | Bit |
4 | Nibble |
8 | Byte |
16 | Word |
32 | Double Word |
64 | Quad Word |
Also, when converting from Binary to Decimal or even from Decimal to Binary, we need to be careful that we do not mix up the two sets of numbers. For example, if we write the digits 10 on the page it could mean the number “ten” if we assume it to be a decimal number, or it could equally be a “1” and a “0” together in binary, which is equal to the number two in the weighted decimal format from above.
One way to overcome this problem when converting binary to decimal numbers and to identify whether the digits or numbers being used are decimal or binary is to write a small number called a “subscript” after the last digit to show the base of the number system being used.
So for example, if we were using a binary number string we would add the subscript “2” to denote a base-2 number so the number would be written as 10_{2}. Likewise, if it was a standard decimal number we would add the subscript “10” to denote a base-10 number so the number would be written as 10_{10}.
Today, as micro-controller or microprocessor systems become increasingly larger, the individual binary digits (bits) are now grouped together into 8’s to form a single BYTE with most computer hardware such as hard drives and memory modules commonly indicate their size in Megabytes or even Gigabytes.
Number of Bytes | Common Name |
1,024 (2^{10}) | kilobyte (kb) |
1,048,576 (2^{20}) | Megabyte (Mb) |
1,073,741,824 (2^{30}) | Gigabyte (Gb) |
a very long number! (2^{40}) | Terabyte (Tb) |
Converting binary to decimal (base-2 to base-10) or decimal to binary numbers (base10 to base-2) can be done in a number of different ways as shown above. When converting decimal numbers to binary numbers it is important to remember which is the least significant bit (LSB), and which is the most significant bit (MSB).
In the next tutorial about Binary Logic we will look at converting binary numbers into Hexadecimal Numbers and vice versa and show that binary numbers can be represented by letters as well as numbers.
Well done
We can more learn………..!
Great tutorial.
Superb unfolding in progressive steps.
Thank you ET.
A very well explained tutorial..Great work and.. .Thank you…
IT is a good thing
can i get help of my questions
The tutorial are very easy to understand, i really appreciate these tutorials
Its amazing and gain few time fast wey
how can covert binary to decimal
1 0 0 1 0 1 b = 37d
32 16 8 4 2 1 b
It goes by scale: 1, 2, 4, 8, 16, 32, 64, 128, etc..
b – binary
d – decimal
one more example:
64 32 16 8 4 2 1
1 0 0 0 0 1 1 b = 67d (64*1 + 32*0 + 16*0 + 8*0 + 4*0 + 2*1 + 1*1)
But it works only binary to decimal..
ðŸ˜‰
how to convertpoint numbers to binarynumerals