#[repr(C)]pub struct i256 {
low: u128,
high: i128,
}Expand description
A signed 256-bit integer
Fields§
§low: u128§high: i128Implementations§
Source§impl i256
impl i256
Sourcepub const fn from_le_bytes(b: [u8; 32]) -> Self
pub const fn from_le_bytes(b: [u8; 32]) -> Self
Create an integer value from its representation as a byte array in little-endian.
Sourcepub const fn from_be_bytes(b: [u8; 32]) -> Self
pub const fn from_be_bytes(b: [u8; 32]) -> Self
Create an integer value from its representation as a byte array in big-endian.
Sourcepub fn from_string(value_str: &str) -> Option<Self>
pub fn from_string(value_str: &str) -> Option<Self>
Create an integer value from its representation as string.
Sourcepub fn from_f64(v: f64) -> Option<Self>
pub fn from_f64(v: f64) -> Option<Self>
Create an optional i256 from the provided f64. Returning None
if overflow occurred
Sourcepub const fn from_parts(low: u128, high: i128) -> Self
pub const fn from_parts(low: u128, high: i128) -> Self
Create an i256 from the provided low u128 and high i128
Sourcepub fn to_i128(self) -> Option<i128>
pub fn to_i128(self) -> Option<i128>
Converts this i256 into an i128 returning None if this would result
in truncation/overflow
Sourcepub const fn to_le_bytes(self) -> [u8; 32]
pub const fn to_le_bytes(self) -> [u8; 32]
Return the memory representation of this integer as a byte array in little-endian byte order.
Sourcepub const fn to_be_bytes(self) -> [u8; 32]
pub const fn to_be_bytes(self) -> [u8; 32]
Return the memory representation of this integer as a byte array in big-endian byte order.
Sourcefn from_bigint_with_overflow(v: BigInt) -> (Self, bool)
fn from_bigint_with_overflow(v: BigInt) -> (Self, bool)
Create an i256 from the provided BigInt returning a bool indicating
if overflow occurred
Sourcepub fn wrapping_abs(self) -> Self
pub fn wrapping_abs(self) -> Self
Computes the absolute value of this i256
Sourcepub fn checked_abs(self) -> Option<Self>
pub fn checked_abs(self) -> Option<Self>
Computes the absolute value of this i256 returning None if Self == Self::MIN
Sourcepub fn wrapping_neg(self) -> Self
pub fn wrapping_neg(self) -> Self
Negates this i256
Sourcepub fn checked_neg(self) -> Option<Self>
pub fn checked_neg(self) -> Option<Self>
Negates this i256 returning None if Self == Self::MIN
Sourcepub fn wrapping_add(self, other: Self) -> Self
pub fn wrapping_add(self, other: Self) -> Self
Performs wrapping addition
Sourcepub fn checked_add(self, other: Self) -> Option<Self>
pub fn checked_add(self, other: Self) -> Option<Self>
Performs checked addition
Sourcepub fn wrapping_sub(self, other: Self) -> Self
pub fn wrapping_sub(self, other: Self) -> Self
Performs wrapping subtraction
Sourcepub fn checked_sub(self, other: Self) -> Option<Self>
pub fn checked_sub(self, other: Self) -> Option<Self>
Performs checked subtraction
Sourcepub fn wrapping_mul(self, other: Self) -> Self
pub fn wrapping_mul(self, other: Self) -> Self
Performs wrapping multiplication
Sourcepub fn checked_mul(self, other: Self) -> Option<Self>
pub fn checked_mul(self, other: Self) -> Option<Self>
Performs checked multiplication
Sourcefn div_rem(self, other: Self) -> Result<(Self, Self), DivRemError>
fn div_rem(self, other: Self) -> Result<(Self, Self), DivRemError>
Division operation, returns (quotient, remainder).
This basically implements [Long division]: <https://en.wikipedia.org/wiki/Division_algorithm>
Sourcefn from_digits(digits: [u64; 4]) -> Self
fn from_digits(digits: [u64; 4]) -> Self
Interpret 4 u64 digits, least significant first, as a i256
Sourcepub fn wrapping_div(self, other: Self) -> Self
pub fn wrapping_div(self, other: Self) -> Self
Performs wrapping division
Sourcepub fn checked_div(self, other: Self) -> Option<Self>
pub fn checked_div(self, other: Self) -> Option<Self>
Performs checked division
Sourcepub fn wrapping_rem(self, other: Self) -> Self
pub fn wrapping_rem(self, other: Self) -> Self
Performs wrapping remainder
Sourcepub fn checked_rem(self, other: Self) -> Option<Self>
pub fn checked_rem(self, other: Self) -> Option<Self>
Performs checked remainder
Sourcepub fn checked_pow(self, exp: u32) -> Option<Self>
pub fn checked_pow(self, exp: u32) -> Option<Self>
Performs checked exponentiation
Sourcepub fn wrapping_pow(self, exp: u32) -> Self
pub fn wrapping_pow(self, exp: u32) -> Self
Performs wrapping exponentiation
Sourcepub const fn is_negative(self) -> bool
pub const fn is_negative(self) -> bool
Returns true if this i256 is negative
Sourcepub const fn is_positive(self) -> bool
pub const fn is_positive(self) -> bool
Returns true if this i256 is positive
Sourcepub const fn leading_zeros(&self) -> u32
pub const fn leading_zeros(&self) -> u32
Returns the number of leading zeros in the binary representation of this i256.
Sourcepub const fn trailing_zeros(&self) -> u32
pub const fn trailing_zeros(&self) -> u32
Returns the number of trailing zeros in the binary representation of this i256.
fn redundant_leading_sign_bits_i256(n: i256) -> u8
fn i256_to_f64(input: i256) -> f64
Trait Implementations§
Source§impl AddAssign for i256
impl AddAssign for i256
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+= operation. Read moreSource§impl ArrowNativeType for i256
impl ArrowNativeType for i256
Source§fn get_byte_width() -> usize
fn get_byte_width() -> usize
Source§impl AsPrimitive<i256> for i16
impl AsPrimitive<i256> for i16
Source§impl AsPrimitive<i256> for i32
impl AsPrimitive<i256> for i32
Source§impl AsPrimitive<i256> for i64
impl AsPrimitive<i256> for i64
Source§impl AsPrimitive<i256> for i8
impl AsPrimitive<i256> for i8
Source§impl AsPrimitive<i256> for u16
impl AsPrimitive<i256> for u16
Source§impl AsPrimitive<i256> for u32
impl AsPrimitive<i256> for u32
Source§impl AsPrimitive<i256> for u64
impl AsPrimitive<i256> for u64
Source§impl AsPrimitive<i256> for u8
impl AsPrimitive<i256> for u8
Source§impl CheckedAdd for i256
impl CheckedAdd for i256
Source§fn checked_add(&self, v: &i256) -> Option<Self>
fn checked_add(&self, v: &i256) -> Option<Self>
None is
returned.Source§impl CheckedDiv for i256
impl CheckedDiv for i256
Source§fn checked_div(&self, v: &i256) -> Option<Self>
fn checked_div(&self, v: &i256) -> Option<Self>
None is returned.Source§impl CheckedMul for i256
impl CheckedMul for i256
Source§fn checked_mul(&self, v: &i256) -> Option<Self>
fn checked_mul(&self, v: &i256) -> Option<Self>
None is returned.Source§impl CheckedNeg for i256
impl CheckedNeg for i256
Source§fn checked_neg(&self) -> Option<Self>
fn checked_neg(&self) -> Option<Self>
None for results that can’t be represented, like signed MIN
values that can’t be positive, or non-zero unsigned values that can’t be negative. Read moreSource§impl CheckedRem for i256
impl CheckedRem for i256
Source§impl CheckedSub for i256
impl CheckedSub for i256
Source§fn checked_sub(&self, v: &i256) -> Option<Self>
fn checked_sub(&self, v: &i256) -> Option<Self>
None is returned.Source§impl DivAssign for i256
impl DivAssign for i256
Source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
/= operation. Read moreSource§impl MulAssign for i256
impl MulAssign for i256
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
*= operation. Read moreSource§impl Num for i256
impl Num for i256
type FromStrRadixErr = ParseI256Error
Source§fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
2..=36). Read moreSource§impl Ord for i256
impl Ord for i256
Source§impl PartialOrd for i256
impl PartialOrd for i256
Source§impl RemAssign for i256
impl RemAssign for i256
Source§fn rem_assign(&mut self, rhs: Self)
fn rem_assign(&mut self, rhs: Self)
%= operation. Read moreSource§impl Signed for i256
impl Signed for i256
Source§fn is_positive(&self) -> bool
fn is_positive(&self) -> bool
Source§fn is_negative(&self) -> bool
fn is_negative(&self) -> bool
Source§impl SubAssign for i256
impl SubAssign for i256
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-= operation. Read moreSource§impl ToPrimitive for i256
impl ToPrimitive for i256
Source§fn to_i64(&self) -> Option<i64>
fn to_i64(&self) -> Option<i64>
self to an i64. If the value cannot be
represented by an i64, then None is returned.Source§fn to_f64(&self) -> Option<f64>
fn to_f64(&self) -> Option<f64>
self to an f64. Overflows may map to positive
or negative inifinity, otherwise None is returned if the value cannot
be represented by an f64. Read moreSource§fn to_u64(&self) -> Option<u64>
fn to_u64(&self) -> Option<u64>
self to a u64. If the value cannot be
represented by a u64, then None is returned.Source§fn to_isize(&self) -> Option<isize>
fn to_isize(&self) -> Option<isize>
self to an isize. If the value cannot be
represented by an isize, then None is returned.Source§fn to_i8(&self) -> Option<i8>
fn to_i8(&self) -> Option<i8>
self to an i8. If the value cannot be
represented by an i8, then None is returned.Source§fn to_i16(&self) -> Option<i16>
fn to_i16(&self) -> Option<i16>
self to an i16. If the value cannot be
represented by an i16, then None is returned.Source§fn to_i32(&self) -> Option<i32>
fn to_i32(&self) -> Option<i32>
self to an i32. If the value cannot be
represented by an i32, then None is returned.Source§fn to_i128(&self) -> Option<i128>
fn to_i128(&self) -> Option<i128>
self to an i128. If the value cannot be
represented by an i128 (i64 under the default implementation), then
None is returned. Read moreSource§fn to_usize(&self) -> Option<usize>
fn to_usize(&self) -> Option<usize>
self to a usize. If the value cannot be
represented by a usize, then None is returned.Source§fn to_u8(&self) -> Option<u8>
fn to_u8(&self) -> Option<u8>
self to a u8. If the value cannot be
represented by a u8, then None is returned.Source§fn to_u16(&self) -> Option<u16>
fn to_u16(&self) -> Option<u16>
self to a u16. If the value cannot be
represented by a u16, then None is returned.Source§fn to_u32(&self) -> Option<u32>
fn to_u32(&self) -> Option<u32>
self to a u32. If the value cannot be
represented by a u32, then None is returned.Source§impl WrappingAdd for i256
impl WrappingAdd for i256
Source§fn wrapping_add(&self, v: &Self) -> Self
fn wrapping_add(&self, v: &Self) -> Self
self + other, wrapping around at the boundary of
the type.Source§impl WrappingMul for i256
impl WrappingMul for i256
Source§fn wrapping_mul(&self, v: &Self) -> Self
fn wrapping_mul(&self, v: &Self) -> Self
self * other, wrapping around at the boundary
of the type.Source§impl WrappingNeg for i256
impl WrappingNeg for i256
Source§fn wrapping_neg(&self) -> Self
fn wrapping_neg(&self) -> Self
-self,
wrapping around at the boundary of the type. Read moreSource§impl WrappingSub for i256
impl WrappingSub for i256
Source§fn wrapping_sub(&self, v: &Self) -> Self
fn wrapping_sub(&self, v: &Self) -> Self
self - other, wrapping around at the boundary
of the type.