numeric.int.operator ≡
Copyright: (c) Microsoft Corporation. All rights reserved.
Integer operators.
template <typename T> inline uint<bitsizeof(T)> abs(T a) §
Compute the absolute value of a. The return type is an
unsigned integer of the same width as a.
template <typename R, typename T> inline R add(T a, T b) §
Add two values of the input type T and return the result
as the output type R, which might be larger. e.g. 3 fits in
a uint2, but 3 + 3 does not.
Example
>>> add<uint3>(3, 3);
6
inline auto div(auto numerator, auto denominator) §
Returns the floor of the quotient when dividing
numerator by denominator.
inline auto ceil_div(auto numerator, auto denominator) §
Returns the ceiling of the quotient when dividing
numerator by denominator.
template <auto Offset = 0> inline auto mod(auto numerator, auto denominator) §
Returns the remainder when dividing numerator by
denominator. Offset is used to to adjust the
range of repeated values. For example, if mod<4, 0>
is applied to the array: [0, 1, 2, 3, 4, 5] the result is:
[0, 1, 2, 3, 0, 1]. If mod<4, 1> is
applied to the same array, the result is:
[4, 1, 2, 3, 4, 1]
template <auto Offset = 0> inline auto div_mod(auto numerator, auto denominator) §
Returns the floor of the quotient and remainder when dividing
numerator by denominator. The quotient is
returned in first. The remainder is returned in
second. Offset is used to to adjust the range
of repeated values. For example, if mod<4, 0> is
applied to the array: [0, 1, 2, 3, 4, 5] the result is:
[0, 1, 2, 3, 0, 1]. If mod<4, 1> is
applied to the same array, the result is:
[4, 1, 2, 3, 4, 1]
template <auto Offset = 0> inline auto ceil_div_mod(auto numerator, auto denominator) §
Returns the ceiling of the quotient and remainder when dividing
numerator by denominator. The quotient is
returned in first. The remainder is returned in
second. Offset is used to to adjust the range
of repeated values. For example, if mod<4, 0> is
applied to the array: [0, 1, 2, 3, 4, 5] the result is:
[0, 1, 2, 3, 0, 1]. If mod<4, 1> is
applied to the same array, the result is:
[4, 1, 2, 3, 4, 1]
inline auto increment(auto a) §
Increment the input by 1.
prop> increment(a) == a + 1
inline auto xor(auto a, auto b) §
Return xor of inputs.
Example
>>> xor(2, 3);
1