The following functions are a collection of intrinsics that implement integral
arithmetic primitives that check for out-of-range results, available by
importing the core.checkedint module.
In all intrinsics, the overflow is sticky, meaning a sequence of operations can be done and overflow need only be checked at the end.
int core.checkedint.adds (int x, int y, ref bool overflow) ¶long core.checkedint.adds (long x, long y, ref bool overflow) ¶Add two signed integers, checking for overflow.
This intrinsic is the same as the GCC built-in function
__builtin_sadd_overflow.
int core.checkedint.addu (int x, int y, ref bool overflow) ¶long core.checkedint.addu (long x, long y, ref bool overflow) ¶Add two unsigned integers, checking for overflow.
This intrinsic is the same as the GCC built-in function
__builtin_uadd_overflow.
int core.checkedint.muls (int x, int y, ref bool overflow) ¶long core.checkedint.muls (long x, long y, ref bool overflow) ¶Multiply two signed integers, checking for overflow.
This intrinsic is the same as the GCC built-in function
__builtin_smul_overflow.
int core.checkedint.mulu (int x, int y, ref bool overflow) ¶long core.checkedint.mulu (long x, long y, ref bool overflow) ¶Multiply two unsigned integers, checking for overflow.
This intrinsic is the same as the GCC built-in function
__builtin_umul_overflow.
int core.checkedint.negs (int x, ref bool overflow) ¶long core.checkedint.negs (long x, ref bool overflow) ¶Negates an integer.
This intrinsic is equivalent to writing the following:
result = __builtin_ssub (0, x, overflow);