0

In object c, how to detect an overflow like this

int a = INT_MAX;
int b = INT_MAX;
int result = a * b;
printf("%d x %d = %d\n",a, b, result);

And it shows

2147483647 x 2147483647 = 1

Can anybody tell me how to detect that kind of arithmetic operation error in object c? Is it possible to use catch exceptions?

Thanks a lot.

0 Answers0