Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

For unsigned integers $ X = 00110101 $ and $ Y = 10110101 $, determine the following values:

$ X + Y = (\text{My answer is}) ~ 11101010 $.

$ X - Y = ~ ??? $

$ Y - X = ~ ??? $

share|improve this question
What have you tried? Perhaps try to define 01-10 and 10-01 in binary first, and then try to tackle your problem. –  gt6989b Feb 20 '13 at 23:57
Another hint: $X-Y = -(Y-X)$. –  gt6989b Feb 20 '13 at 23:58
Yes I understand that this would come out to -10000000. However, "unsigned" integers can't be negative...so how do I do this then –  Silent Man Feb 21 '13 at 0:04
Please stop defacing your questions. –  Andres Caicedo Feb 21 '13 at 5:38
Amzoti and I have spent some effort to answer your question. Why did you delete it? –  Ross Millikan Feb 21 '13 at 6:14

4 Answers 4

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$$

share|improve this answer
Good work, Amzoti! +1 –  amWhy May 1 '13 at 2:15
@amWhy: I have to admit that this has never been a good way to have defined it in general. I suppose this makes it easy for logic circuits, but hard for humans! :-) –  Amzoti May 1 '13 at 2:17
I agree wholeheartedly! But I enjoy doing "two's complement" arithmetic...I don't know why...I guess it's an exercise in logic, to some extent... –  amWhy May 1 '13 at 2:17

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$$

share|improve this answer
@SilentMan: yes, the high order bit is not taken as a sign, it is taken as a bit of the number. So in $8$ bits you can represent the numbers $0$ through $2^8-1=255$, while with signed numbers you can represent $-128$ through $127$ in two's complement –  Ross Millikan Feb 21 '13 at 0:22
"Unsigned" computer arithmetic usually means that the operations are done $\bmod 2^n$, where $n$ is the word size. It does not mean that $X-Y$ is undefined when $X<Y$, but rather that the result is $X-Y+2^n$. –  MJD Feb 21 '13 at 0:25
@SilentMan: I would say you do two's complement to represent negative numbers. It is one representation, sign/magnitude is another. –  Ross Millikan Feb 21 '13 at 0:28
@SilentMan:$-128_{10}=10000000$ in two's complement as shown here If you have more bits, you put more $1$'s on the left. You can't represent $+128_{10}$ in a single byte of two's complement. –  Ross Millikan Feb 21 '13 at 0:46

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

share|improve this answer

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.