If you only want to look at operations on integer literals, that could be done with a macro, but I’m not sure how useful it would be.
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.
I doubt that this can be done at runtime without a substantial performance hit, but you are welcome to try to define a type that behaves in this way.
I understood. But, I really do not know I want something that, at every integer operation (+, * and ^) it checks the operands and, if overflow will happen, then change the type to a representation with higher bit. I have no idea how to code this in Julia.
It does not support (at least it is not documented) the function ^.
I want to learn new things
I want to see the performance hit when doing such things like check the type and promoting if necessary.
Actually, I am thinking of a macro that overload / change (do not know the correct name) the operations. Something like, change + to another function that performs the verification as I described. This macro will be used just trigger such behavior like:
@check_overflow f100 = C1*Δt^2 + C2*Δt^3
However, if I give up and use SafeIntegers, I would do something like:
Nice! I will see The macro I mentioned is because I just want to do this in some parts of the code, because there are other in which I know it is not necessary. Hence, I think if I can trigger this behavior only when necessary, the performance hit will not be big (at least I hope).
Anyway, in some tests here with SafeIntegers and such things, I am starting to see that my best approach in terms of performance is to convert everything to Float64 just as MATLAB does