I'm making a small program solving basic math operations (*
, /
, +
, -
) and I'm using long long int
(64-bit number) so I can do math operations with big numbers.
But there is a problem. I can check the operands if they are not over or under limit (using LONG_LONG_MAX
and LONG_LONG_MIN
).
But when I (for example) multiply two very big numbers (which cause overflow of long long int
) the LONG_LONG_MAX
check doesn't work. Rather, the result is for -4.
Is there any chance in C/C++ check that? For example some try catch construction?