1
$\begingroup$

Does the arithmetic operation -

102 (base 10)- 39 (base 10), represented in 8-bit, when converted to binary have an overflow or underflow?

My Ans - It has no problem. I mean there is neither overflow nor underflow because 8- bit numbers can range from -127 to +127. The answer to the binary operation is +63 and so it is within the range. Hence there is no over flow or under flow. Is my answer correct?

$\endgroup$
2
$\begingroup$

Yes, you are entirely correct.

There would certainly be overflow if we were adding $39_{10}$ to $102_{10}$ in two's complement, since the sum exceeds $127$, which is the maximum positive base 10 value representable in two's complement. However, there is no problem whatsoever when subtracting $39_{10}$ from $102_{10}$.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ Thank you so much. I was getting confused because in doing the arithmetic operation ( addition of a negative number 102+(-39), I had a 1 remaining (carry). I thought that was overflow. But thanks for verifying my answer. REally appreciate it. $\endgroup$ – CuriousBeing Oct 27 '13 at 14:27
  • $\begingroup$ You're welcome! ;-) $\endgroup$ – amWhy Oct 27 '13 at 14:36
  • $\begingroup$ If you're here, can you please explain what underflow is? A situation that could best describe underflow? $\endgroup$ – CuriousBeing Oct 28 '13 at 1:07
0
$\begingroup$

Yes it's correct.....................................

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ Can you pls tell me one more thing - is 2's complement taken only for negative numbers? $\endgroup$ – CuriousBeing Oct 27 '13 at 10:02
  • $\begingroup$ I think you're asking if you can use the same method to convert a negative binary number to a positive one. The answer is yes. $\endgroup$ – George Tomlinson Oct 27 '13 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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