John has created a calculator that works only with int8 variables. Before executing math operations, he needs to know if the result will have an overflow. Check three operations: "+", "-", and "*" for possible overflow with given numbers.
Remember that when using the
int type, we won't have overflow with numbers from the int8 range, because the int type has a much bigger range. To check the overflow, you need to perform an operation first with the int8 values, then with the int values, and finally compare their values. If they are different, we have an overflow.