Idiom # 86: Check if integer multiplication will overflow
For all integers with wrap-around semantics (i.e. all the standard types i32,
u64, etc.), there are two ways to check for overflow on multiplication. First,
overflowOnMul checks if a multiplication of two
values would overflow. Next, there is a multiplication operator
*? that performs overflow checking and returns a
that can be checked afterwards.
infix * would result in a runtime error in case of an
overflow if debug checks are enabled. If overflow semantics are desired,
infix *° has to be used.