I need help to create a macro to do the following:
- On every integer operation, check if overflow will happen.
- If it does, then promote the arguments to integer representations with higher number of bits.
I do not know how the compiler will work, but I am wondering if this can be done without much performance decrease if the operands do not lead to an integer overflow.
My usage is because I have in my code things like:
f100 = C1*Δt^2 + C2*Δt^3
Δt is selected by the user and can be a very big number. Hence, if the user input a big integer, the
^ will overflow.
Of course I can always promote the
Δt to Float64, but I want to try this to see how it works.