Open
Description
Normally, we handle overflows with Math.*Exact
operations, but we don't have one in this case, because:
In cases where the size is int or long and overflow errors need to be detected, the methods addExact, subtractExact, multiplyExact, and toIntExact throw an ArithmeticException when the results overflow. For other arithmetic operations such as divide, absolute value, increment, decrement, and negation overflow occurs only with a specific minimum or maximum value and should be checked against the minimum or maximum as appropriate.
See https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html
Possible solution proposed by @fniephaus: smarr/SOMns#292