9. Binary to Decimal
• Technique
• Multiply each bit by 2n, where n is the “weight” of the bit
• The weight is the position of the bit, starting from 0 on
the right
• Add the results
10. Example
1010112 => (1 x 20)+(1 x 21)+(0 x 22)+(1 x 23)+(0 x 24)
+(1 x 25)
= 1+2+0+8+0+32
= 4310
Bit “0”
12. Decimal to Binary
• Technique
• Divide by two, keep track of the remainder
• First remainder is bit 0 (LSB, least-significant bit)
• Second remainder is bit 1
• Etc.
19. 1’s and 2’s Complement:
The 1’s complement of a binary number is simply obtained by
replacing every 1 by 0 , and every 0 by 1.
The 2’s complement of a binary number can be obtained in
two ways:
By adding 1 to the 1’s complement.
Start the binary number from right. Leave the binary digits
unchanged until the first 1 appear, then replace every 1 by
0 , and every 0 by 1.
20. Complements of Binary Numbers
• 1’s complement
• Change all 1s to 0s and all 0s to 1s
1 0 1 0 1 0 1 0
0 1 0 1 0 1 0 1
21. Ex 1: Obtain the two’s complement of the binary number 1011010.110
First solution
Second solution
22. Ex 2: Calculate the following binary Subtraction: 1101.101 – 11011.11 ,
then verify the result in decimal System.
Solution