How to avoid issues like integer overflow in models based on differential equations with some states values ranging from 10^12 to 10^-12 ?
use floating point numbers instead of integers. E.G.
help?> Base.Checked Checked The Checked module provides arithmetic functions for the built-in signed and unsigned Integer types which throw an error when an overflow occurs. They are named like checked_sub, checked_div, etc. In addition, add_with_overflow, sub_with_overflow, mul_with_overflow return both the unchecked results and a boolean value denoting the presence of an overflow.
Also discussed here.
I think the simplest solution in this case is to use floating point numbers, as mentioned in the first reply. Although I don’t know the details, I guess that
Float64 is used throughout the computation anyway. Checked arithmetic for integers introduces more complication than necessary.
For values up to
Int64 is fine,
10^12 uses roughly 40 bits, and
Int64 has 64 bits. However, does not make any sense to worry about integer overflow if your values are not integers, and
10^-12 most certainly is not an integer, you can only be using
Float64 here anyway.