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
A*B - C*D
signed long long int A, B, C, D;
You could try breaking the equation into smaller components which don't overflow.
AB - CD = [ A(B - N) - C( D - M )] + [AN - CM] = ( AK - CJ ) + ( AN - CM) where K = B - N J = D - M
If the components still overflow you could break them into smaller components recursively and then recombine.