+1 vote
1.2k views
If we take a n bit register to store result of addition/subtraction of two n bit unsigned binary numbers , then if the end-carry occurs , then the end-carry is the part of the result . Is it overflow or not ?

If we take a n bit register to store result of addition/subtraction two n bit signed binary numbers , then if the end-carry occurs ,then it is the sign-bit of the result  .  Is it overflow or not ?
| 1.2k views

"If we take a n bit register to store result of addition/subtraction of two n bit unsigned binary numbers , then if the end-carry occurs , then the end-carry is the part of the result . Is it overflow or not ?"

It is indeed overflow. But overflow means nothing for unsigned operations. It is meant only for signed operations. If the carry happens out of the most significant bit position, then result is wrong and this is denoted by CARRY flag for unsigned numbers.

"If we take a n bit register to store result of addition/subtraction two n bit signed binary numbers , then if the end-carry occurs ,then it is the sign-bit of the result  .  Is it overflow or not ?"

Yes. It is overflow. And we get wrong answer here (since sign changes). And this is exactly why overflow flag is used for signed operations.

Overflow is useful for signed operations while carry flag is useful for unsigned operations.

http://teaching.idallen.com/dat2343/10f/notes/040_overflow.txt

by Veteran (434k points)
selected
0
@arjun sir, in unsigned numbers does we call overflow as carry instead of overflow?
0
Not really. Because overflow and carry are flags in CPU. They cannot have multiple meaning based on whether input is signed or unsigned. Most CPUs don't distinguish between signed and unsigned numbers (since they are represented using 2's complement form) and carry out operation.
0
so then what we will say when two unsigned numbers of n - bits gives result in ( n + 1 ) bits. It must definitely overflow the register which is for n bits. So, it should be called as overflow
0
Yes, it overflows the registers but we call it "carry" :)
0
okay......but sir why we don't consider the overflow in unsigned numbers as it actually happens.
0
We consider it but we just call it carry. For signed numbers this happens for one bit position before than that of unsigned and its called overflow. Since, both signed and unsigned numbers uses the same status register, they are named so- this is my guess.
0
olrite sir....thnku
IF YOU GET A CARRY IN UNSIGNED ARITHMETIC THEN IT IS A MUST OVERFLOW CONDITION

BUT FOR A SIGNED IT MAY OR MAY BE NOT . IN A SIGNED YOU GET OVERFLOW CONDITION ONLY WHEN ADDITION OF 2 NEGATIVE NUMBER GIVE POSTIVE AND ADDITION OF 2 POSITIVE NUMBER GIVE NEGATIVE RESULT :)
by Active (2.6k points)