I'm adding really big numbers (a lot of them). I'm supposed to detect overflow errors. I did it years ago in Assembly by checking bits, but I've never done it in C++.
long long a = pow (2, 62.0); long long b = pow (2, 62.0); a += b; // overflow - how do I detect this?
I know I can create a temp variable, set it equal to a + b, then if a and b are positive and the temp variable is negative, then overflow has occurred. But is there a way to check those bits instead?