For unsigned integers $ X = 00110101 $ and $ Y = 10110101 $, determine the following values:
$ X + Y = (\text{My answer is}) ~ 11101010 $.
$ X - Y = ~ ??? $
$ Y - X = ~ ??? $
$\endgroup$ 74 Answers
$\begingroup$Your answer is correct for $X+Y = 11101010$
Hint (Algorithm): $X-Y$
Determine $Y’s$ $2’s$ complement $X+$ (2’s complement of $Y$)
If $X \ge Y$, an end carry will result. Discard the end carry.
If $X \lt Y$, no end carry will result. To obtain the answer in a familiar form, take the 2’s complement of the sum and place a negative sign in front.
You may want to display in a different form, but you did not specify (hint: convert the first answer to 2's complement form).
$$X - Y = -10000000 ~~\text{and}~~ Y - X = 10000000$$
$\endgroup$ 3 $\begingroup$For $Y-X$ you do it just like base $10$. In this case there are no borrows. For unsigned, there is no answer to $X-Y$ because negative numbers cannot be represented.
$$\ \ \ 10110101\\ \underline{-00110101}\\\ \ \ 10000000$$
$\endgroup$ 4 $\begingroup$For X=00110101 and Y=10110101,
Binary Addition X + Y = 11101010
Binary Subtraction X - Y = -10000000
Binary Multiplication X * Y = 0010010101111001
Binary Division X / Y = 0000
Check results @ Binary Arithmetic Calculator
$\endgroup$ $\begingroup$Step: 1. Take 2's compliment of -ve number.
Step: 2. Add it to +ve number
Step: 3. If most significant bit is 0 then write answer with avoiding end carry
Step: 4. If most significant bit is 1 then take 2's compliment of answer again and place negative sign with answer
X-Y => 00110101 -10110101 Take 2's compliment of 10110101 =>01001010 =>00111011
Then add it to first number =>10000000
We know that MSB is 1. So the answer should be in negative. To make it negative take 2's compliment of answer again => 01111111 => 10000000 X-Y =>-10000000
For Y-X Y => 10110101 X =>-10110101 Take 2's compliment to X => 01001010 -X => 01001011
Add it to Y 110000000 There is an end carry so answer will be in positive automatically. Ignore and carry and write answer 10000000
$\endgroup$