In: Computer Science
On rare occasions, computers have been designed which use one’s complement base 2 representation. Consider the decimal expression below: 7 + (-3)= 4
(a) Convert all three numbers to 4-bit one’s complement base 2.
(b) Perform the one’s complement base 2 operation and verify that the sum is as expected.
One's Complement is used to represent signed binary numbers Positive numbers are simply represented as Binary number number no change is there but. When we have a negative number then we take one's complement of its positive sign representation .
Lets see how we can write given number in One's Complement
Part A)
1. +7 = 0111 ( Normal binary as number is +ve)
2. -3 = One's Complement ( + 3) = One's Complement( 0011) = 1100
3. +4 = 0100
This is how we can represent all these number
Part B)
Now Lets Perform Addition Operation
7 + (-3) = 4
0111
+1100
-----------
0100
Here we get Result as 0100
Now to get equivalent Decimal .
1. MSB Bit represent the Sign of number . If MSB=0 then number is Positive else Negative
2. Rest n-1 bits represent the Magnitude
Here MSB =0 So result is positive
Magnitude = 100 = 4
Hence we get Result as = +4
So We have Also verify the Operation using One's Complement Notation and we got same result as expected.
This is how we work on One's complement and can represent negative numbers and used to perform operations
If u like the answer do Upvote it and have any doubt ask in comments
Thank You