I need to compute an expression which looks like:
A*B - C*D
, where their types are: signed long long int A, B, C, D;
Each number can be really big (not
You could consider computing a greatest common factor for all your values, and then dividing them by that factor before doing your arithmetic operations, then multiplying again. This assumes that such a factor exists, however (for example, if A
, B
, C
and D
happen to be relatively prime, they won't have a common factor).
Similarly, you could consider working on log-scales, but this is going to be a little scary, subject to numerical precision.