1.6. Base Conversions
Decimal to Binary Conversion
Alternative 1 – “Subtract the weight method”
Steps:
♦ Find the largest power of 2 (2n) that can be subtracted out of the decimal number
♦ Take the result and subtract (2n-1) from it
If the result is not negative then that bit is one
If the result is negative, then that bit is zero and the result equals the result from
step 1
♦ Repeat step 2 until the result is exactly 0
Example: convert (49) 10 to a binary number
Alternative 2 – “Division by 2 method”
Steps:
♦ Divide the decimal number by 2
Remainder is the least significant bit (most right bit)
Quotient is used in the next step
♦ Divide quotient by 2
Remainder is the next significant bit (next left bit)
Quotient is used in the next step
♦ Repeat previous step until quotient is 0
Example: convert (49) 10 to a binary number
Binary to Decimal Conversion – “Add the weight method”
Step:
Simply multiply each bit with its weight and add to get the decimal number
Example: Convert (110001) 2 to a decimal number
(110001) 2 = ( 1* 2^5 + 1* 2^4 + 0* 2^3 + 0* 2^2 + 0* 2^1 + 1* 2^0 ) 10 = (49) 10
Binary ↔ Octal Conversion - “Group of 3 method”
Remainder
2|49 1 (LSB)
2|24 0
2|12 0
2| 6 0
2| 3 1
2| 1 1 (MSB)
2| 0 Stop
(49) 10 (110001) 2
49
-
----
17
2
n
Results
17
-
----
1
Binary # ( 1 1 0 0 0 1) 2
1
-
----
-
1
-
----
-
1
-
----
-
1
-
----
0 When =0, done