Conversion Between Decimal and Binary Representations
Conversion from Binary to Decimal
The conversion of a binary number to decimal can be done in two ways:
Method 1: Multiply each binary number by its position-value, and add the results together. The rightmost bit has a position value 1, the next 2, the value at the third position is 4, fourth 8 and so on (See figure below)
Example: 1101 = 8x1 + 4x1 + 1x1 (or simply, 8+4+1) = 13
Method 2: The advantage of this method is that you need not remember or compute position-values. Starting from leftmost bit, multiply the first bit by 2 and add to the next. Multiply the result by 2 and add to the third bit. Multiply the result by 2 and add to the fourth bit. Continue this process till you have reached the rightmost bit.
Conversion from Decimal to Binary
Here also we give two equivalent methods for converting a decimal number to binary.
Method 1: Subract the largest power of two, and change the bit at that position to 1. Keep subtracting the next largest possible power from the remainder, each time assigning a bit value 1 at the corresponding bit position. Repeat the process till you get a 1 or 0 for the last bit.
Method 2: In this method, we repeatedly divide the given decimal number by 2, and the remainders are placed from right to left:
Example: 43
43 ÷ 2: Quotient 21, remainder 1: Result > 1
21 ÷ 2: Quotient 10, remainder 1: Result > 1 1
10 ÷ 2: Quotient 5, remainder 0: Result > 0 1 1
5 ÷ 2: Quotient 2, remainder 1: Result > 1 0 1 1
2 ÷ 2: Quotient 1, remainder 0: Result > 0 1 0 1 1
1 ÷ 2: Quotient 0, remainder 1: Result > 1 0 1 0 1 1
The process stops when the quotient becomes 0
Binary addition
There are four rules for binary addition:
In fouth case, a binary addition is creating a sum of 1 + 1 = 10 i.e. 0 is written in the given column and a carry of 1 over to the next column.
Example - addition:
Binary subtraction
Subtraction and Borrow, these two words will be used very frequently for binary Subtraction. There are four rules for binary subtraction:
Example - Subtraction:
Binary multiplication
Binary multiplication is similar to decimal multiplication. It is simpler than decimal multiplication because only 0s and 1s are involved. There are four rules for binary multiplication:
Multiplication is always 0, whenever at least one input is 0.
Example - Multiplication:
Binary division
There are four parts in any division: Dividend, Divisor, quotient, and remainder.
The result is always not defined, whenever the divisor is 0. Binary division is similar to decimal division. It is called as the long division procedure.
Example - division: