Struct ethers_core::types::I256 [−][src]
pub struct I256(_);
Expand description
Little-endian 256-bit signed integer.
Implementations
Creates an I256 from a sign and an absolute value. Returns the value and a bool that is true if the conversion caused an overflow.
Creates an I256 from an absolute value and a negative flag. Returns
None
if it would overflow an I256
.
Splits a I256 into its absolute value and negative flag.
Coerces an unsigned integer into a signed one. If the unsigned integer
is greater than the greater than or equal to 1 << 255
, then the result
will overflow into a negative value.
Returns the signed integer as a unsigned integer. If the value of self
negative, then the two’s complement of its absolute value will be
returned.
Conversion to i32 with overflow checking
Panics
Panics if the number is outside the range [i32::MIN
, i32::MAX
].
Conversion to u32 with overflow checking
Panics
Panics if the number is outside the range [0
, u32::MAX
].
Conversion to i64 with overflow checking
Panics
Panics if the number is outside the range [i64::MIN
, i64::MAX
].
Conversion to u64 with overflow checking
Panics
Panics if the number is outside the range [0
, u64::MAX
].
Conversion to i128 with overflow checking
Panics
Panics if the number is outside the range [i128::MIN
, i128::MAX
].
Conversion to u128 with overflow checking
Panics
Panics if the number is outside the range [0
, u128::MAX
].
Conversion to isize with overflow checking
Panics
Panics if the number is outside the range [isize::MIN
, isize::MAX
].
Conversion to usize with overflow checking
Panics
Panics if the number is outside the range [0
, usize::MAX
].
Convert from a decimal string.
Convert from a hexadecimal string.
Returns true
if self
is positive and false
if the number is zero
or negative.
Returns true
if self
is negative and false
if the number is zero
or negative.
Returns true
if self
is negative and false
if the number is zero
or positive.
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
(e.g., I256::MIN
for values of type I256
), then the minimum value
will be returned again and true will be returned for an overflow
happening.
Checked absolute value. Computes self.abs()
, returning None
if
self == MIN
.
Saturating absolute value. Computes self.abs()
, returning MAX
if
self == MIN
instead of overflowing.
Wrapping absolute value. Computes self.abs()
, wrapping around at the
boundary of the type.
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,
then the minimum value will be returned again and true
will be
returned for an overflow happening.
Checked negation. Computes self.neg()
, returning None
if
self == MIN
.
Saturating negation. Computes self.neg()
, returning MAX
if
self == MIN
instead of overflowing.
Wrapping negation. Computes self.neg()
, returning MIN
if
self == MIN
instead of overflowing.
Returns the number of ones in the binary representation of self
.
Returns the number of zeros in the binary representation of self
.
Returns the number of leading zeros in the binary representation of
self
.
Returns the number of leading zeros in the binary representation of
self
.
Write to the slice in big-endian format.
Write to the slice in little-endian format.
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.
Checked addition. Returns None if overflow occurred.
Addition which saturates at the maximum value (Self::max_value()).
Wrapping addition.
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.
Checked subtraction. Returns None if overflow occurred.
Subtraction which saturates at zero.
Wrapping subtraction.
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.
Checked multiplication. Returns None if overflow occurred.
Multiplication which saturates at the maximum value..
Wrapping multiplication.
Calculates self
/ rhs
Returns a tuple of the division along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.
Checked division. Returns None if overflow occurred or if rhs == 0.
Division which saturates at the maximum value.
Wrapping division.
Calculates self
% rhs
Returns a tuple of the remainder along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.
Checked remainder. Returns None if overflow occurred or rhs == 0
Wrapping remainder. Returns the result of the operation % regardless of whether or not the division overflowed.
Calculates the quotient of Euclidean division of self by rhs.
This computes the integer n
such that self = n * rhs + self.rem_euclid(rhs)
,
with 0 <= self.rem_euclid(rhs) < rhs
.
In other words, the result is self / rhs
rounded to the integer n
such that self >= n * 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 least non-negative 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)
.
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.
Checked Euclidean division. Computes self.div_euclid(rhs)
,
returning None if rhs == 0
or the division results in overflow.
Wrapping Euclidean division.
Computes self.div_euclid(rhs)
, wrapping around at the boundary of the type.
Wrapping only occurs 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.
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 if rhs == 0
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 when rhs == 0
Checked Euclidean remainder. Computes self.rem_euclid(rhs)
,
returning None
if rhs == 0
or the division results in overflow.
Raises self to the power of exp
.
Returns a tuple of the exponentiation along with a bool indicating whether an overflow happened.
Raises self to the power of exp
. Returns None if overflow occurred.
Raises self to the power of exp
, saturating at the numeric bounds
instead of overflowing.
Wrapping powolute value. Computes self.pow()
, wrapping around at the
boundary of the type.
Trait Implementations
The native ABI type this type represents.
Performs the +=
operation. Read more
Performs the &=
operation. Read more
Performs the |=
operation. Read more
Performs the ^=
operation. Read more
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Performs the /=
operation. Read more
Performs the *=
operation. Read more
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
Performs the %=
operation. Read more
Performs the <<=
operation. Read more
Performs the <<=
operation. Read more
Performs the <<=
operation. Read more
Performs the <<=
operation. Read more
Performs the <<=
operation. Read more
Performs the <<=
operation. Read more
Performs the <<=
operation. Read more
Performs the <<=
operation. Read more
Performs the <<=
operation. Read more
Performs the <<=
operation. Read more
Performs the <<=
operation. Read more
Performs the <<=
operation. Read more
Performs the <<=
operation. Read more
Performs the <<=
operation. Read more
Implements the logical shift right operation
Implements the logical shift right operation
Implements the logical shift right operation
Implements the logical shift right operation
Implements the logical shift right operation
Implements the logical shift right operation
Implements the logical shift right operation
Implements the logical shift right operation
Implements the logical shift right operation
Implements the logical shift right operation
Implements the logical shift right operation
Implements the logical shift right operation
Implements the logical shift right operation
Implements the logical shift right operation
Performs the >>=
operation. Read more
Performs the >>=
operation. Read more
Performs the >>=
operation. Read more
Performs the >>=
operation. Read more
Performs the >>=
operation. Read more
Performs the >>=
operation. Read more
Performs the >>=
operation. Read more
Performs the >>=
operation. Read more
Performs the >>=
operation. Read more
Performs the >>=
operation. Read more
Performs the >>=
operation. Read more
Performs the >>=
operation. Read more
Performs the >>=
operation. Read more
Performs the >>=
operation. Read more
Performs the -=
operation. Read more
Converts a Token
into expected type.
Converts a specified type back into token.
Auto Trait Implementations
impl RefUnwindSafe for I256
impl UnwindSafe for I256
Blanket Implementations
Mutably borrows from an owned value. Read more