Struct Subspace :: sus :: num :: i32

struct i32 final
{ ... };

A 32-bit signed integer.

See the namespace level documentation for more.

Static Data Members

static const u32 BITS

The size of and i32 in bits.

static const i32 MAX

The largest value that can be represented by an i32.

static const int MAX_PRIMITIVE

The largest value that can be represented by an i32, as a native C++ primitive.

static const i32 MIN

The smallest value that can be represented by an i32.

static const int MIN_PRIMITIVE

The smallest value that can be represented by an i32, as a native C++ primitive.

Static Methods

template <class P>
i32(P v)
requires
sus::num::UnsignedPrimitiveEnumClass<P>
::sus::mem::size_of<P>() < ::sus::mem::size_of<_primitive>()

Construction from unsigned enum class types where no bits are lost.

For conversions from types with a larger range use try_from. For lossy conversions use the Cast concept with sus::cast<i32>(x).

template <class P>
i32(P v)
requires
sus::num::SignedPrimitiveEnumClass<P>
::sus::mem::size_of<P>() <= ::sus::mem::size_of<_primitive>()

Construction from signed enum class types where no bits are lost.

For conversions from types with a larger range use try_from. For lossy conversions use the Cast concept with sus::cast<i32>(x).

template <class P>
i32(P v)
requires
sus::num::SignedPrimitiveEnum<P>
::sus::mem::size_of<P>() <= ::sus::mem::size_of<_primitive>()

Construction from signed enum types where no bits are lost.

For conversions from types with a larger range use try_from. For lossy conversions use the Cast concept with sus::cast<i32>(x).

template <class P>
i32(P v)
requires
sus::num::SignedPrimitiveInteger<P>
::sus::mem::size_of<P>() <= ::sus::mem::size_of<_primitive>()

Construction from signed primitive types where no bits are lost.

For conversions from types with a larger range use try_from. For lossy conversions use the Cast concept with sus::cast<i32>(x).

template <class P>
i32(P v)
requires
sus::num::UnsignedPrimitiveInteger<P>
::sus::mem::size_of<P>() < ::sus::mem::size_of<_primitive>()

Construction from unsigned primitive types where no bits are lost.

For conversions from types with a larger range use try_from. For lossy conversions use the Cast concept with sus::cast<i32>(x).

template <class S>
i32(S v)
requires
sus::num::Signed<S>
::sus::mem::size_of<S>() <= ::sus::mem::size_of<_primitive>()

Construction from signed types where no bits are lost.

For conversions from types with a larger range use try_from. For lossy conversions use the Cast concept with sus::cast<i32>(x).

template <class P>
i32(P v)
requires
sus::num::UnsignedPrimitiveEnum<P>
::sus::mem::size_of<P>() < ::sus::mem::size_of<_primitive>()

Construction from unsigned enum types where no bits are lost.

For conversions from types with a larger range use try_from. For lossy conversions use the Cast concept with sus::cast<i32>(x).

Default constructor, which sets the integer to 0.

Satisfies the Default concept.

The trivial copy and move constructors are implicitly declared, as is the trivial destructor.

template <class U>
i32(U v)
requires
sus::num::Unsigned<U>
::sus::mem::size_of<U>() < ::sus::mem::size_of<_primitive>()

Construction from unsigned types where no bits are lost.

For conversions from types with a larger range use try_from. For lossy conversions use the Cast concept with sus::cast<i32>(x).

template <class S>
static auto from(S s) -> i32
requires
sus::num::Signed<S>
::sus::mem::size_of<S>() <= ::sus::mem::size_of<_primitive>()

Constructs a i32 from a signed integer type (i8, i16, i32, etc) where no bits are lost.

For conversions from types with a larger range use try_from. For lossy conversions use the Cast concept with sus::cast<i32>(x).

template <class S>
static auto from(S s) -> i32
requires
sus::num::Unsigned<S>
::sus::mem::size_of<S>() < ::sus::mem::size_of<_primitive>()

Constructs a i32 from an unsigned integer type (unsigned int, unsigned long, etc) where no bits are lost.

For conversions from types with a larger range use try_from. For lossy conversions use the Cast concept with sus::cast<i32>(x).

template <class S>
static auto from(S s) -> i32
requires
sus::num::SignedPrimitiveInteger<S>
::sus::mem::size_of<S>() <= ::sus::mem::size_of<_primitive>()

Constructs a i32 from a signed primitive integer type (int, long, etc) where no bits are lost.

For conversions from types with a larger range use try_from. For lossy conversions use the Cast concept with sus::cast<i32>(x).

template <class S>
static auto from(S s) -> i32
requires
SignedPrimitiveEnum<S> || SignedPrimitiveEnumClass<S>
::sus::mem::size_of<S>() <= ::sus::mem::size_of<_primitive>()

Constructs a i32 from a signed enum type (or enum class) where no bits are lost.

For conversions from types with a larger range use try_from. For lossy conversions use the Cast concept with sus::cast<i32>(x).

template <class S>
static auto from(S s) -> i32
requires
sus::num::UnsignedPrimitiveInteger<S>
::sus::mem::size_of<S>() < ::sus::mem::size_of<_primitive>()

Constructs a i32 from an unsigned primitive integer type (unsigned int, unsigned long, etc) where no bits are lost.

For conversions from types with a larger range use try_from. For lossy conversions use the Cast concept with sus::cast<i32>(x).

template <class S>
static auto from(S s) -> i32
requires
UnsignedPrimitiveEnum<S> || UnsignedPrimitiveEnumClass<S>
::sus::mem::size_of<S>() < ::sus::mem::size_of<_primitive>()

Constructs a i32 from an unsigned enum type (or enum class) where no bits are lost.

For conversions from types with a larger range use try_from. For lossy conversions use the Cast concept with sus::cast<i32>(x).

static auto from_be(i32 x) -> i32

Converts an integer from big endian to the target's endianness.

On big endian this is a no-op. On little endian the bytes are swapped.

static auto from_be_bytes(const sus::collections::Array<u8, ::sus::mem::size_of<_primitive>()>& bytes) -> i32

Create an integer value from its representation as a byte array in big endian.

static auto from_le(i32 x) -> i32

Converts an integer from little endian to the target's endianness.

On little endian this is a no-op. On big endian the bytes are swapped.

static auto from_le_bytes(const sus::collections::Array<u8, ::sus::mem::size_of<_primitive>()>& bytes) -> i32

Create an integer value from its representation as a byte array in little endian.

static auto from_ne_bytes(const sus::collections::Array<u8, ::sus::mem::size_of<_primitive>()>& bytes) -> i32

Create an integer value from its memory representation as a byte array in native endianness.

As the target platform's native endianness is used, portable code likely wants to use from_be_bytes or from_le_bytes, as appropriate instead.

static auto from_product(Iterator<i32> auto&& it) -> i32
requires
sus::mem::IsMoveRef<decltype(it)>

Constructs a i32 from an Iterator by computing the product of all elements in the itertor.

This method should rarely be called directly, as it is used to satisfy the Product concept so that Iterator::product can be called for iterators over i32.

To handle overflow without panicing, instead of iter.product(), use iter.product<OverflowInteger<i32>>().

Panics

This method will panic if the product of all values overflows and overflow checks are enabled (they are by default), and will wrap if overflow checks are disabled (not the default).

See overflow checks for controlling this behaviour.

static auto from_sum(Iterator<i32> auto&& it) -> i32
requires
sus::mem::IsMoveRef<decltype(it)>

Constructs a i32 from an Iterator by computing the sum of all elements in the itertor.

This method should rarely be called directly, as it is used to satisfy the Sum concept so that Iterator::sum can be called for iterators over i32.

To handle overflow without panicing, instead of iter.sum(), use iter.sum<OverflowInteger<i32>>().

Panics

This method will panic if the sum of all values overflows and overflow checks are enabled (they are by default), and will wrap if overflow checks are disabled (not the default).

See overflow checks for controlling this behaviour.

template <class S>
static auto try_from(S s) -> Result<i32, TryFromIntError>
requires
sus::num::Signed<S>

Try to construct a i32 from a signed integer type (i8, i16, i32, etc).

Returns an error if the source value is outside of the range of i32.

template <class U>
static auto try_from(U u) -> Result<i32, TryFromIntError>
requires
sus::num::Unsigned<U>

Try to construct a i32 from an unsigned integer type (u8, u16, u32, etc).

Returns an error if the source value is outside of the range of i32.

template <class S>
static auto try_from(S s) -> Result<i32, TryFromIntError>
requires
sus::num::SignedPrimitiveInteger<S>

Tries to construct a i32 from a signed primitive integer type (int, long, etc).

Returns an error if the source value is outside of the range of i32.

template <class S>
static auto try_from(S s) -> Result<i32, TryFromIntError>
requires
SignedPrimitiveEnum<S> || SignedPrimitiveEnumClass<S>

Tries to construct a i32 from a signed enum type (or enum class).

Returns an error if the source value is outside of the range of i32.

template <class U>
static auto try_from(U u) -> Result<i32, TryFromIntError>
requires
sus::num::UnsignedPrimitiveInteger<U>

Constructs a i32 from an unsigned primitive integer type (unsigned int, unsigned long, etc).

Returns an error if the source value is outside of the range of i32.

template <class U>
static auto try_from(U u) -> Result<i32, TryFromIntError>
requires
UnsignedPrimitiveEnum<U> || UnsignedPrimitiveEnumClass<U>

Constructs a i32 from an unsigned enum type (or enum class).

Returns an error if the source value is outside of the range of i32.

Methods

auto abs() const& -> i32

Computes the absolute value of itself.

Panics

The absolute value of i32::MIN cannot be represented as an i32, and attempting to calculate it will panic when overflow checks are enabled. When disabled (not the default), wrapping abs is performed.

See overflow checks for controlling this behaviour.

auto abs_diff(i32 other) const& -> u32

Computes the absolute difference between self and other.

This function always returns the correct answer without overflow or panics by returning an unsigned integer.

auto as_mut_ptr() & -> int32_t*

Returns a mutable pointer to the underlying C++ primitive value type.

This allows Subspace numerics be used with APIs that expect a pointer to a C++ primitive type.

auto as_ptr() const& -> const int32_t*
auto as_ptr() && -> const int32_t*
deleted

Returns a const pointer to the underlying C++ primitive value type.

This allows Subspace numerics be used with APIs that expect a pointer to a C++ primitive type.

auto checked_abs() const& -> Option<i32>

Checked absolute value. Computes abs, returning None if the current value is MIN.

auto checked_add(i32 rhs) const& -> Option<i32>

Checked integer addition. Computes self + rhs, returning None if overflow occurred.

Checked integer addition with an unsigned rhs. Computes self + rhs, returning None if overflow occurred.

auto checked_div(i32 rhs) const& -> Option<i32>

Checked integer division. Computes self / rhs, returning None if rhs == 0 or the division results in overflow.

auto checked_div_euclid(i32 rhs) const& -> Option<i32>

Checked Euclidean division. Computes self.div_euclid(rhs), returning None if rhs == 0 or the division results in overflow.

auto checked_log(i32 base) const& -> Option<u32>

Returns the logarithm of the number with respect to an arbitrary base, rounded down.

Returns None if the number is negative or zero, or if the base is not at least 2.

This method might not be optimized owing to implementation details; checked_log2 can produce results more efficiently for base 2, and checked_log10 can produce results more efficiently for base 10.

auto checked_log10() const& -> Option<u32>

Returns the base 10 logarithm of the number, rounded down.

Returns None if the number is negative or zero.

auto checked_log2() const& -> Option<u32>

Returns the base 2 logarithm of the number, rounded down.

Returns None if the number is negative or zero.

auto checked_mul(i32 rhs) const& -> Option<i32>

Checked integer multiplication. Computes self * rhs, returning None if overflow occurred.

auto checked_neg() const& -> Option<i32>

Checked negation. Computes -self, returning None if self == MIN.

auto checked_pow(u32 rhs) const& -> Option<i32>

Checked exponentiation. Computes pow, returning None if overflow occurred.

auto checked_rem(i32 rhs) const& -> Option<i32>

Checked integer remainder. Computes self % rhs, returning None if rhs == 0 or the division results in overflow.

auto checked_rem_euclid(i32 rhs) const& -> Option<i32>

Checked Euclidean remainder. Computes self.rem_euclid(rhs), returning None if rhs == 0 or the division results in overflow.

auto checked_shl(u64 rhs) const& -> Option<i32>

Checked shift left. Computes self << rhs, returning None if rhs is larger than or equal to the number of bits in self.

auto checked_shr(u64 rhs) const& -> Option<i32>

Checked shift right. Computes self >> rhs, returning None if rhs is larger than or equal to the number of bits in self.

auto checked_sub(i32 rhs) const& -> Option<i32>

Checked integer subtraction. Computes self - rhs, returning None if overflow occurred.

Checked integer subtraction with an unsigned rhs. Computes self - rhs, returning None if overflow occurred.

auto count_ones() const& -> u32

Returns the number of ones in the binary representation of the current value.

auto count_zeros() const& -> u32

Returns the number of zeros in the binary representation of the current value.

auto div_euclid(i32 rhs) const& -> i32

Calculates the quotient of Euclidean division of self by rhs.

This computes the integer q such that self = q * rhs + r, with r = self.rem_euclid(rhs) and 0 <= r < abs(rhs).

In other words, the result is self / rhs rounded to the integer q such that self >= q * rhs. If self > 0, this is equal to round towards zero; if self < 0, this is equal to round towards +/- infinity.

Panics

This function will panic if rhs is 0 or the division results in overflow.

auto is_negative() const& -> bool

Returns true if the current value is positive and false if the number is zero or negative.

auto is_positive() const& -> bool

Returns true if the current value is negative and false if the number is zero or positive.

auto leading_ones() const& -> u32

Returns the number of leading ones in the binary representation of the current value.

auto leading_zeros() const& -> u32

Returns the number of leading zeros in the binary representation of the current value.

auto log(i32 base) const& -> u32

Returns the logarithm of the number with respect to an arbitrary base, rounded down.

This method might not be optimized owing to implementation details; log2 can produce results more efficiently for base 2, and log10 can produce results more efficiently for base 10.

Panics

When the number is negative, zero, or if the base is not at least 2.

auto log10() const& -> u32

Returns the base 10 logarithm of the number, rounded down.

Panics

When the number is zero or negative the function will panic.

auto log2() const& -> u32

Returns the base 2 logarithm of the number, rounded down.

Panics

When the number is zero or negative the function will panic.

auto overflowing_abs() const& -> Tuple<i32, bool>

Computes the absolute value of self.

Returns a tuple of the absolute version of self along with a boolean indicating whether an overflow happened. If self is the minimum value (i.e. i32::MIN, then the minimum value will be returned again and true will be returned for an overflow happening.

auto overflowing_add(i32 rhs) const& -> Tuple<i32, bool>

Calculates self + rhs.

Returns a tuple of the addition along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.

auto overflowing_add_unsigned(u32 rhs) const& -> Tuple<i32, bool>

Calculates self + rhs with an unsigned rhs.

Returns a tuple of the addition along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.

auto overflowing_div(i32 rhs) const& -> Tuple<i32, bool>

Calculates the divisor when self is divided by rhs.

Returns a tuple of the divisor along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would occur then self is returned.

Panics

This function will panic if rhs is 0.

auto overflowing_div_euclid(i32 rhs) const& -> Tuple<i32, bool>

Calculates the quotient of Euclidean division self.div_euclid(rhs).

Returns a tuple of the divisor along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would occur then self is returned.

Panics

This function will panic if rhs is 0.

auto overflowing_mul(i32 rhs) const& -> Tuple<i32, bool>

Calculates the multiplication of self and rhs.

Returns a tuple of the multiplication along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.

auto overflowing_neg() const& -> Tuple<i32, bool>

Negates self, overflowing if this is equal to the minimum value.

Returns a tuple of the negated version of self along with a boolean indicating whether an overflow happened. If self is the minimum value (i.e. i32::MIN, then the minimum value will be returned again and true will be returned for an overflow happening.

auto overflowing_pow(u32 exp) const& -> Tuple<i32, bool>

Raises self to the power of exp, using exponentiation by squaring.

Returns a tuple of the exponentiation along with a bool indicating whether an overflow happened.

auto overflowing_rem(i32 rhs) const& -> Tuple<i32, bool>

Calculates the remainder when self is divided by rhs.

Returns a tuple of the remainder after dividing along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would occur then 0 is returned.

Panics

This function will panic if rhs is 0.

auto overflowing_rem_euclid(i32 rhs) const& -> Tuple<i32, bool>

Overflowing Euclidean remainder. Calculates self.rem_euclid(rhs).

Returns a tuple of the remainder after dividing along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would occur then 0 is returned.

Panics

This function will panic if rhs is 0.

auto overflowing_shl(u64 rhs) const& -> Tuple<i32, bool>

Shifts self left by rhs bits.

Returns a tuple of the shifted version of self along with a boolean indicating whether the shift value was larger than or equal to the number of bits. If the shift value is too large, then value is masked by (N-1) where N is the number of bits, and this value is then used to perform the shift.

auto overflowing_shr(u64 rhs) const& -> Tuple<i32, bool>

Shifts self right by rhs bits.

Returns a tuple of the shifted version of self along with a boolean indicating whether the shift value was larger than or equal to the number of bits. If the shift value is too large, then value is masked by (N-1) where N is the number of bits, and this value is then used to perform the shift.

auto overflowing_sub(i32 rhs) const& -> Tuple<i32, bool>

Calculates self - rhs.

Returns a tuple of the subtraction along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.

auto overflowing_sub_unsigned(const u32& rhs) const& -> Tuple<i32, bool>

Calculates self - rhs with an unsigned rhs.

Returns a tuple of the subtraction along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.

auto pow(u32 rhs) const& -> i32

Raises self to the power of exp, using exponentiation by squaring.

Panics

This function will panic on overflow if overflow checks are enabled (they are by default) and will wrap if overflow checks are disabled (not the default).

See overflow checks for controlling this behaviour.

auto rem_euclid(i32 rhs) const& -> i32

Calculates the least nonnegative remainder of self (mod rhs).

This is done as if by the Euclidean division algorithm – given r = self.rem_euclid(rhs), self = rhs * self.div_euclid(rhs) + r, and 0 <= r < abs(rhs).

Panics

This function will panic if rhs is 0 or the division results in overflow.

auto reverse_bits() const& -> i32

Reverses the order of bits in the integer. The least significant bit becomes the most significant bit, second least-significant bit becomes second most-significant bit, etc.

auto rotate_left(u64 n) const& -> i32

Shifts the bits to the left by a specified amount, n, wrapping the truncated bits to the end of the resulting integer.

Please note this isn't the same operation as the << shifting operator!

auto rotate_right(u64 n) const& -> i32

Shifts the bits to the right by a specified amount, n, wrapping the truncated bits to the beginning of the resulting integer.

Please note this isn't the same operation as the >> shifting operator!

auto saturating_abs() const& -> i32

Saturating absolute value. Computes abs, returning MAX if the current value is MIN instead of overflowing.

auto saturating_add(i32 rhs) const& -> i32

Saturating integer addition. Computes self + rhs, saturating at the numeric bounds instead of overflowing.

Saturating integer addition with an unsigned rhs. Computes self + rhs, saturating at the numeric bounds instead of overflowing.

auto saturating_div(i32 rhs) const& -> i32

Saturating integer division. Computes self / rhs, saturating at the numeric bounds instead of overflowing.

Panics

This function will panic if rhs is 0.

auto saturating_mul(i32 rhs) const& -> i32

Saturating integer multiplication. Computes self * rhs, saturating at the numeric bounds instead of overflowing.

auto saturating_neg() const& -> i32

Saturating integer negation. Computes -self, returning MAX if self == MIN instead of overflowing.

auto saturating_sub(i32 rhs) const& -> i32

Saturating integer subtraction. Computes self - rhs, saturating at the numeric bounds instead of overflowing.

auto saturating_sub_unsigned(const u32& rhs) const& -> i32

Saturating integer subtraction with an unsigned rhs. Computes self - rhs, saturating at the numeric bounds instead of overflowing.

auto signum() const& -> i32

Returns a number representing sign of the current value.

  • 0 if the number is zero
  • 1 if the number is positive
  • -1 if the number is negative
auto swap_bytes() const& -> i32

Reverses the byte order of the integer.

auto to_be() const& -> i32

Converts self to big endian from the target's endianness.

On big endian this is a no-op. On little endian the bytes are swapped.

auto to_be_bytes() const& -> sus::collections::Array<u8, ::sus::mem::size_of<_primitive>()>

Return the memory representation of this integer as a byte array in big-endian (network) byte order.

auto to_le() const& -> i32

Converts self to little endian from the target's endianness.

On little endian this is a no-op. On big endian the bytes are swapped.

auto to_le_bytes() const& -> sus::collections::Array<u8, ::sus::mem::size_of<_primitive>()>

Return the memory representation of this integer as a byte array in little-endian byte order.

auto to_ne_bytes() const& -> sus::collections::Array<u8, ::sus::mem::size_of<_primitive>()>

Return the memory representation of this integer as a byte array in native byte order.

As the target platform's native endianness is used, portable code should use to_be_bytes or to_le_bytes, as appropriate, instead.

auto trailing_ones() const& -> u32

Returns the number of trailing ones in the binary representation of the current value.

auto trailing_zeros() const& -> u32

Returns the number of trailing zeros in the binary representation of the current value.

Unchecked integer addition. Computes self + rhs, assuming overflow cannot occur.

Safety

This results in undefined behavior when self + rhs > i32::MAX or self + rhs < i32::MIN, i.e. when checked_add would return None.

Unchecked integer multiplication. Computes self * rhs, assuming overflow cannot occur.

Safety

This results in undefined behavior when self * rhs > i32::MAX or self * rhs < i32::MIN, i.e. when checked_mul would return None.

Unchecked integer subtraction. Computes self - rhs, assuming overflow cannot occur.

Safety

This results in undefined behavior when self - rhs > i32::MAX or self - rhs < i32::MIN, i.e. when checked_sub would return None.

auto unsigned_abs() const& -> u32

Computes the absolute value of self without any wrapping or panicking.

auto wrapping_abs() const& -> i32

Wrapping (modular) absolute value. Computes abs, wrapping around at the boundary of the type.

The only case where such wrapping can occur is when one takes the absolute value of the negative minimal value for the type; this is a positive value that is too large to represent in the type. In such a case, this function returns MIN itself.

auto wrapping_add(i32 rhs) const& -> i32

Wrapping (modular) addition. Computes self + rhs, wrapping around at the boundary of the type.

auto wrapping_add_unsigned(u32 rhs) const& -> i32

Wrapping (modular) addition with an unsigned rhs. Computes self + rhs, wrapping around at the boundary of the type.

auto wrapping_div(i32 rhs) const& -> i32

Wrapping (modular) division. Computes self / rhs, wrapping around at the boundary of the type.

The only case where such wrapping can occur is when one divides MIN / -1 on a signed type (where MIN is the negative minimal value for the type); this is equivalent to -MIN, a positive value that is too large to represent in the type. In such a case, this function returns MIN itself.

Panics

This function will panic if rhs is 0.

auto wrapping_div_euclid(i32 rhs) const& -> i32

Wrapping Euclidean division. Computes self.div_euclid(rhs), wrapping around at the boundary of the type.

Wrapping will only occur in MIN / -1 on a signed type (where MIN is the negative minimal value for the type). This is equivalent to -MIN, a positive value that is too large to represent in the type. In this case, this method returns MIN itself.

Panics

This function will panic if rhs is 0.

auto wrapping_mul(i32 rhs) const& -> i32

Wrapping (modular) multiplication. Computes self * rhs, wrapping around at the boundary of the type.

auto wrapping_neg() const& -> i32

Wrapping (modular) negation. Computes -self, wrapping around at the boundary of the type.

The only case where such wrapping can occur is when one negates MIN on a signed type (where MIN is the negative minimal value for the type); this is a positive value that is too large to represent in the type. In such a case, this function returns MIN itself.

auto wrapping_pow(u32 exp) const& -> i32

Wrapping (modular) exponentiation. Computes pow, wrapping around at the boundary of the type.

auto wrapping_rem(i32 rhs) const& -> i32

Wrapping (modular) remainder. Computes self % rhs, wrapping around at the boundary of the type.

Such wrap-around never actually occurs mathematically; implementation artifacts make x % y invalid for MIN / -1 on a signed type (where MIN is the negative minimal value). In such a case, this function returns 0.

auto wrapping_rem_euclid(i32 rhs) const& -> i32

Wrapping Euclidean remainder. Computes self.rem_euclid(rhs), wrapping around at the boundary of the type.

Wrapping will only occur in MIN % -1 on a signed type (where MIN is the negative minimal value for the type). In this case, this method returns 0.

Panics

This function will panic if rhs is 0.

auto wrapping_shl(u64 rhs) const& -> i32

what you want instead.

auto wrapping_shr(u64 rhs) const& -> i32

Panic-free bitwise shift-right; yields self >> mask(rhs), where mask removes any high-order bits of rhs that would cause the shift to exceed the bitwidth of the type.

Note that this is not the same as a rotate-right; the RHS of a wrapping shift-right is restricted to the range of the type, rather than the bits shifted out of the LHS being returned to the other end. The Subspace integer types all implement a rotate_right function, which may be what you want instead.

auto wrapping_sub(i32 rhs) const& -> i32

Wrapping (modular) subtraction. Computes self - rhs, wrapping around at the boundary of the type.

auto wrapping_sub_unsigned(const u32& rhs) const& -> i32

Wrapping (modular) subtraction with an unsigned rhs. Computes self - rhs, wrapping around at the boundary of the type.

Conversions

template <class U>
operator U() const
requires
sus::num::SignedPrimitiveInteger<U>
::sus::mem::size_of<U>() >= ::sus::mem::size_of<_primitive>()

Conversion from the numeric type to a C++ primitive type.

This converts to signed primitives which are at least as large as the i32.

auto d = int32_t{3_i32};  // Compiles.
auto e = int32_t(3_i32);  // Compiles.
int32_t f = 3_i32;  // Compiles.

auto d = uint16_t{3_i32};  // Does not compile.
auto e = uint16_t(3_i32);  // Does not compile.
uint16_t f = 3_i32;  // Does not compile.

Potentially-lossy type conversions can be forced through the Cast concept, such as sus::cast<uint32_t>(3_i32) or sus::cast<int16_t>(3_i32), or even sus::cast<u32>(3_i32).

Operators

auto operator%=(i32 r) & -> void

Assigns the remainder of dividing itself by r.

Satisfies the RemAssign<i32> concept.

Panics

This operator will panic when dividing by zero or when division will overflow.

auto operator&=(i32 r) & -> void

Assigns the bitwise AND of itself and r.

Satisfies the BitAndAssign<i32> concept.

Panics

This operator will panic when dividing by zero or when division will overflow.

auto operator*=(i32 r) & -> void

Multiplies itself by r.

Satisfies the MulAssign<i32> concept.

Panics

This operation will panic on overflow if overflow checks are enabled (they are by default) and will wrap if overflow checks are disabled (not the default).

See overflow checks for controlling this behaviour.

auto operator+=(i32 r) & -> void

Adds r to itself.

Satisfies the AddAssign<i32> concept.

Panics

This operation will panic on overflow if overflow checks are enabled (they are by default) and will wrap if overflow checks are disabled (not the default).

See overflow checks for controlling this behaviour.

auto operator-() const& -> i32

Computes the negation of the current value.

Satisfies the Neg<i32> concept.

Panics

This operation will panic on overflow (self == i32::MIN) if overflow checks are enabled (they are by default) and will wrap if overflow checks are disabled (not the default).

See overflow checks for controlling this behaviour.

auto operator-=(i32 r) & -> void

Subtracts r from itself.

Satisfies the SubAssign<i32> concept.

Panics

This operation will panic on overflow if overflow checks are enabled (they are by default) and will wrap if overflow checks are disabled (not the default).

See overflow checks for controlling this behaviour.

auto operator/=(i32 r) & -> void

Divides itself by r.

Satisfies the DivAssign<i32> concept.

Panics

This operator will panic when dividing by zero or when division will overflow.

auto operator<<=(u64 r) & -> void

Shifts itself left by r bits.

Satisfies the ShlAssign<i32> concept.

Panics

This function will panic when r is not less than the number of bits in i32 if overflow checks are enabled (they are by default) and will perform a wrapping shift if overflow checks are disabled (not the default).

See overflow checks for controlling this behaviour.

template <class S>
auto operator=(S v) -> i32&
requires
sus::num::Signed<S>
::sus::mem::size_of<S>() <= ::sus::mem::size_of<_primitive>()

Assignment from signed types where no bits are lost.

For conversions from types with a larger range use try_from. For lossy conversions use the Cast concept with sus::cast<i32>(x).

template <class P>
auto operator=(P v) -> i32&
requires
sus::num::SignedPrimitiveInteger<P>
::sus::mem::size_of<P>() <= ::sus::mem::size_of<_primitive>()

Assignment from signed primitive types where no bits are lost.

For conversions from types with a larger range use try_from. For lossy conversions use the Cast concept with sus::cast<i32>(x).

template <class P>
auto operator=(P v) -> i32&
requires
sus::num::SignedPrimitiveEnum<P>
::sus::mem::size_of<P>() <= ::sus::mem::size_of<_primitive>()

Assignment from signed enum types where no bits are lost.

For conversions from types with a larger range use try_from. For lossy conversions use the Cast concept with sus::cast<i32>(x).

auto operator>>=(u64 r) & -> void

Shifts itself right by r bits.

Performs sign extension, copying the sign bit to the right if its set.

Satisfies the ShrAssign<i32> concept.

Panics

This function will panic when r is not less than the number of bits in i32 if overflow checks are enabled (they are by default) and will perform a wrapping shift if overflow checks are disabled (not the default).

auto operator^=(i32 r) & -> void

Assigns the bitwise XOR of itself and r.

Satisfies the BitXorAssign<i32> concept.

auto operator|=(i32 r) & -> void

Assigns the bitwise OR of itself and r.

Satisfies the BitOrAssign<i32> concept.

auto operator~() const& -> i32

Computes the bitwise complement (bitwise inverse) of the current value.

Satisfies the BitNot<i32> concept.

Data Members

The inner primitive value. Prefer to cast to the desired primitive type, such as with int32_t{n} for a numeric value n.