I'm working with signed 16 bit wide variables. When adding, subtracting etc, can i detect the carry and overflow the following way:
I store the result in a 32bit wide variable, and then check the 17th bit (bits from 0-16 represent the value, and if there's carry or overflow the 17h bit should be 1 - overflow)? If it's one then it's an overflow/carry, if it's zero - it isn't. Can carry happen without overflow, or vice versa, when working with 16b values?
I searched StackOverflow, but i was unable to find a clear answer to my question.