pub struct i256(_);
Expand description

Large integer type

The type is composed of little-endian ordered 64-bit words, which represents its inner representation.

Implementations

Converts the object to a raw pointer

Converts the object to a mutable raw pointer

Returns the underlying array of words constituting large integer

Returns the underlying array of words constituting large integer

Constructs integer type from the underlying array of words.

Zero value

Value for 1

Bit dimension

Length of the integer in bytes

Length of the inner representation in 64-bit words

Returns whether specific bit number is set to 1 or not

Returns lower 32 bits of the number as u32

Returns lower 64 bits of the number as u32

Returns the number of leading ones in the binary representation of self.

Returns the number of leading zeros in the binary representation of self.

Returns the number of trailing ones in the binary representation of self.

Returns the number of trailing zeros in the binary representation of self.

Creates the integer value from a byte array using big-endian encoding

Creates the integer value from a byte slice using big-endian encoding

Creates the integer value from a byte array using little-endian encoding

Creates the integer value from a byte slice using little-endian encoding

Convert the integer into a byte array using big-endian encoding

Convert a integer into a byte array using little-endian encoding

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

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

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.

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

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

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

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.

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

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

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

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

Calculates self / rhs

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

Wrapping (modular) division. Calculates 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.

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

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

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.

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.

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

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 (the default in Rust); if self < 0, this is equal to round towards +/- infinity.

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.

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.

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

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).

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.

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.

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

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

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

Wrapping (modular) negation. Computes -self, wrapping around at the boundary of the type. Since unsigned types do not have negative equivalents all applications of this function will wrap (except for -0). For values smaller than the corresponding signed type’s maximum the result is the same as casting the corresponding signed value. Any larger values are equivalent to MAX + 1 - (val - MAX - 1) where MAX is the corresponding signed type’s maximum.

Minimum value

Maximum value

Return the least number of bits needed to represent the number

Calculates self * 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.

Trait Implementations

The resulting type after applying the + operator.

Performs the + operation. Read more

Performs the += operation. Read more

The resulting type after applying the & operator.

Performs the & operation. Read more

Performs the &= operation. Read more

The resulting type after applying the | operator.

Performs the | operation. Read more

Performs the |= operation. Read more

The resulting type after applying the ^ operator.

Performs the ^ operation. Read more

Performs the ^= operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Formats the value using the given formatter. Read more

The resulting type after applying the / operator.

Performs the / operation. Read more

Performs the /= operation. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

The resulting type after applying the * operator.

Performs the * operation. Read more

Performs the *= operation. Read more

The resulting type after applying the - operator.

Performs the unary - operation. Read more

The resulting type after applying the ! operator.

Performs the unary ! operation. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

The resulting type after applying the % operator.

Performs the % operation. Read more

Performs the %= operation. Read more

The resulting type after applying the << operator.

Performs the << operation. Read more

Performs the <<= operation. Read more

The resulting type after applying the >> operator.

Performs the >> operation. Read more

Performs the >>= operation. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

Performs the -= operation. Read more

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.