CSC116 ยท 2081 ยท 5 marks
Given A=46 and B=35 represent them in binary and perform A-B using 1's complement method.
Given A=46 and B=35 represent them in binary and perform A-B using 1's complement method. [5]
A โ B Using 1's Complement Method
Given
- $A = 46$ (minuend)
- $B = 35$ (subtrahend)
- Operation: $A - B$ using 1's complement.
Solution
Convert to 8-bit binary
$46_{10}$: $32+8+4+2 = 46 \Rightarrow 0010,1110$
$35_{10}$: $32+2+1 = 35 \Rightarrow 0010,0011$
| Decimal | Binary (8-bit) |
|---|---|
| $A = 46$ | $0010,1110$ |
| $B = 35$ | $0010,0011$ |
1's complement of B (invert all bits)
$$B = 0010,0011 ;\Rightarrow; \overline{B} = 1101,1100$$
Add A and 1's complement of B
0010 1110 (A)
+ 1101 1100 (1's comp of B)
-----------
1 0000 1010
^
carry out = 1
End-around carry
A carry out of the MSB occurred, so add it back to the sum:
0000 1010
+ 1
-----------
0000 1011
Result
$$0000,1011_2 = 8 + 2 + 1 = 11_{10}$$
Since a carry-out (end-around carry) was produced, the result is positive.
Check: $46 - 35 = 11$ โ
Summary
| Step | Value |
|---|---|
| $A$ | $0010,1110$ |
| $B$ | $0010,0011$ |
| $\overline{B}$ | $1101,1100$ |
| $A + \overline{B}$ | $1\ 0000,1010$ |
| After end-around carry | $0000,1011$ |
| Final Result | $0000,1011_2 = 11_{10}$ |
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.