Is this sum of Binary Numbers an Overflow?

332 Views Asked by At

I have a question of the likes of 21 + 11 I converted each number to binary getting:

010101

+

001011

I got a result of : $100000$ which is $32$ in decimal

Thus it is correct that $21+11 = 32$. However, since the signed bit is a 1, which means its negative, does that mean their is an overflow? I'm really confused on this. Does a Carry out also mean theirs an overflow?

1

There are 1 best solutions below

6
On BEST ANSWER

You have to define first what length your binary strings are.

For your case: If you have binary strings of length 6 then there is no overflow but if your strings are of length 5 then you have overflow because you need one more place to represent your result.

As for the sign bit, then you have to define again in what form the binary strings are given

For example $111$ in signed form is equal to $-3$ but in unsigned form the same three bits $111$ are equal to $7$