Uint256

Struct Uint256 

Source
pub struct Uint256(pub [u64; 4]);
Expand description

Little-endian large integer type

Tuple Fields§

§0: [u64; 4]

Implementations§

Source§

impl Uint256

Source

pub const ZERO: Self

Source

pub const MIN: Self = Self::ZERO

Source

pub const MAX: Self

Source

pub const BITS: u32 = 256u32

Source

pub const BYTES: usize = 32usize

Source

pub const LIMBS: usize = 4usize

Source

pub fn from_u64(n: u64) -> Self

Source

pub fn from_u128(n: u128) -> Self

Source

pub fn as_u128(self) -> u128

Source

pub fn as_u64(self) -> u64

Source

pub fn is_zero(self) -> bool

Source

pub fn bits(&self) -> u32

Return the least number of bits needed to represent the number

Source

pub fn leading_zeros(&self) -> u32

Source

pub fn overflowing_shl(self, s: u32) -> (Self, bool)

Source

pub fn wrapping_shl(self, s: u32) -> Self

Source

pub fn overflowing_shr(self, s: u32) -> (Self, bool)

Source

pub fn overflowing_add(self, other: Self) -> (Self, bool)

Source

pub fn overflowing_add_u64(self, other: u64) -> (Self, bool)

Source

pub fn overflowing_sub(self, other: Self) -> (Self, bool)

Source

pub fn overflowing_mul_u64(self, other: u64) -> (Self, bool)

Multiplication by u64

Source

pub fn carrying_mul_u64(self, other: u64) -> (Self, u64)

Source

pub fn overflowing_mul(self, other: Self) -> (Self, bool)

Source

pub fn from_le_bytes(bytes: [u8; 32]) -> Self

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

Source

pub fn from_be_bytes(bytes: [u8; 32]) -> Self

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

Source

pub fn to_le_bytes(self) -> [u8; 32]

Convert’s the Uint into little endian byte array

Source

pub fn to_be_bytes(self) -> [u8; 32]

Convert’s the Uint into big endian byte array

Source

pub fn to_be_bytes_var(self) -> Vec<u8>

Source

pub fn div_rem_u64(self, other: u64) -> (Self, u64)

Source

pub fn as_f64(&self) -> f64

Source

pub fn div_rem(self, other: Self) -> (Self, Self)

Source

pub fn mod_inverse(self, prime: Self) -> Option<Self>

Assumes self < prime

Source

pub fn iter_be_bits(self) -> impl ExactSizeIterator<Item = bool> + FusedIterator

Source

pub fn from_hex(hex: &str) -> Result<Self, Error>

Converts a Self::BYTES*2 hex string interpreted as big endian, into a Uint

Source

pub fn from_be_bytes_var(bytes: &[u8]) -> Result<Self, TryFromSliceError>

Source

pub fn as_bigint(&self) -> Result<BigInt, Error>

Source

pub fn to_bigint(self) -> Result<BigInt, Error>

Source§

impl Uint256

Source

pub fn from_compact_target_bits(bits: u32) -> Self

Source

pub fn compact_target_bits(self) -> u32

Computes the target value in float format from BigInt format.

Trait Implementations§

Source§

impl Add<u64> for Uint256

Source§

type Output = Uint256

The resulting type after applying the + operator.
Source§

fn add(self, other: u64) -> Uint256

Performs the + operation. Read more
Source§

impl Add for Uint256

Source§

type Output = Uint256

The resulting type after applying the + operator.
Source§

fn add(self, other: Uint256) -> Uint256

Performs the + operation. Read more
Source§

impl Binary for Uint256

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl BitAnd for Uint256

Source§

type Output = Uint256

The resulting type after applying the & operator.
Source§

fn bitand(self, other: Uint256) -> Uint256

Performs the & operation. Read more
Source§

impl BitOr for Uint256

Source§

type Output = Uint256

The resulting type after applying the | operator.
Source§

fn bitor(self, other: Uint256) -> Uint256

Performs the | operation. Read more
Source§

impl BitXor for Uint256

Source§

type Output = Uint256

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, other: Uint256) -> Uint256

Performs the ^ operation. Read more
Source§

impl Clone for Uint256

Source§

fn clone(&self) -> Uint256

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Uint256

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Uint256

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for Uint256

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Uint256

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Div<u64> for Uint256

Source§

type Output = Uint256

The resulting type after applying the / operator.
Source§

fn div(self, other: u64) -> Uint256

Performs the / operation. Read more
Source§

impl Div for Uint256

Source§

type Output = Uint256

The resulting type after applying the / operator.
Source§

fn div(self, other: Uint256) -> Uint256

Performs the / operation. Read more
Source§

impl From<Uint256> for Uint320

Source§

fn from(u: Uint256) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for Uint256

Source§

fn from(x: u64) -> Self

Converts to this type from the input type.
Source§

impl FromHex for Uint256

Source§

impl Hash for Uint256

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

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

impl LowerHex for Uint256

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl MemSizeEstimator for Uint256

Source§

fn estimate_mem_units(&self) -> usize

Estimates the number of units this object holds in memory where the unit byte size is usually a constant known to the caller as well (and hence we avoid computing it over and over)
Source§

fn estimate_size(&self, mem_mode: MemMode) -> usize

Estimates the size of this object depending on the passed mem mode
Source§

fn estimate_mem_bytes(&self) -> usize

Estimates the (deep) size of this object in bytes (including heap owned inner data)
Source§

impl Mul<u64> for Uint256

Source§

type Output = Uint256

The resulting type after applying the * operator.
Source§

fn mul(self, other: u64) -> Uint256

Performs the * operation. Read more
Source§

impl Mul for Uint256

Source§

type Output = Uint256

The resulting type after applying the * operator.
Source§

fn mul(self, other: Uint256) -> Uint256

Performs the * operation. Read more
Source§

impl Not for Uint256

Source§

type Output = Uint256

The resulting type after applying the ! operator.
Source§

fn not(self) -> Uint256

Performs the unary ! operation. Read more
Source§

impl Ord for Uint256

Source§

fn cmp(&self, other: &Uint256) -> Ordering

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

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq<u128> for Uint256

Source§

fn eq(&self, other: &u128) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<u64> for Uint256

Source§

fn eq(&self, other: &u64) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for Uint256

Source§

fn eq(&self, other: &Uint256) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd<u128> for Uint256

Source§

fn partial_cmp(&self, other: &u128) -> Option<Ordering>

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

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<u64> for Uint256

Source§

fn partial_cmp(&self, other: &u64) -> Option<Ordering>

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

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd for Uint256

Source§

fn partial_cmp(&self, other: &Uint256) -> Option<Ordering>

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

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a> Product<&'a Uint256> for Uint256

Source§

fn product<I: Iterator<Item = &'a Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by multiplying the items.
Source§

impl Product for Uint256

Source§

fn product<I: Iterator<Item = Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by multiplying the items.
Source§

impl Rem<u64> for Uint256

Source§

type Output = u64

The resulting type after applying the % operator.
Source§

fn rem(self, other: u64) -> u64

Performs the % operation. Read more
Source§

impl Rem for Uint256

Source§

type Output = Uint256

The resulting type after applying the % operator.
Source§

fn rem(self, other: Uint256) -> Uint256

Performs the % operation. Read more
Source§

impl Serialize for Uint256

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl Shl<u32> for Uint256

Source§

type Output = Uint256

The resulting type after applying the << operator.
Source§

fn shl(self, shift: u32) -> Uint256

Performs the << operation. Read more
Source§

impl Shr<u32> for Uint256

Source§

type Output = Uint256

The resulting type after applying the >> operator.
Source§

fn shr(self, shift: u32) -> Uint256

Performs the >> operation. Read more
Source§

impl Sub for Uint256

Source§

type Output = Uint256

The resulting type after applying the - operator.
Source§

fn sub(self, other: Uint256) -> Uint256

Performs the - operation. Read more
Source§

impl<'a> Sum<&'a Uint256> for Uint256

Source§

fn sum<I: Iterator<Item = &'a Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl Sum for Uint256

Source§

fn sum<I: Iterator<Item = Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl ToHex for &Uint256

Source§

fn to_hex(&self) -> String

Source§

impl ToHex for Uint256

Source§

fn to_hex(&self) -> String

Source§

impl TryFrom<&Uint256> for BigInt

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: &Uint256) -> Result<BigInt, Self::Error>

Performs the conversion.
Source§

impl TryFrom<JsValue> for Uint256

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(js_value: JsValue) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Uint256> for BigInt

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Uint256) -> Result<BigInt, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Uint256> for Uint192

Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Uint256) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Uint256> for u128

Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Uint256) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Uint320> for Uint256

Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
Source§

fn try_from(value: Uint320) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for Uint256

Source§

impl Eq for Uint256

Source§

impl StructuralPartialEq for Uint256

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Any for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Source§

fn type_name(&self) -> &'static str

Source§

impl<T> AnySync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T, U> ExactFrom<T> for U
where U: TryFrom<T>,

Source§

fn exact_from(value: T) -> U

Source§

impl<T, U> ExactInto<U> for T
where U: ExactFrom<T>,

Source§

fn exact_into(self) -> U

§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> OverflowingInto<U> for T
where U: OverflowingFrom<T>,

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> RoundingInto<U> for T
where U: RoundingFrom<T>,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> SaturatingInto<U> for T
where U: SaturatingFrom<T>,

Source§

impl<T> ToBinaryString for T
where T: Binary,

Source§

fn to_binary_string(&self) -> String

Returns the String produced by Ts Binary implementation.

§Examples
use malachite_base::strings::ToBinaryString;

assert_eq!(5u64.to_binary_string(), "101");
assert_eq!((-100i16).to_binary_string(), "1111111110011100");
Source§

impl<T> ToDebugString for T
where T: Debug,

Source§

fn to_debug_string(&self) -> String

Returns the String produced by Ts Debug implementation.

§Examples
use malachite_base::strings::ToDebugString;

assert_eq!([1, 2, 3].to_debug_string(), "[1, 2, 3]");
assert_eq!(
    [vec![2, 3], vec![], vec![4]].to_debug_string(),
    "[[2, 3], [], [4]]"
);
assert_eq!(Some(5).to_debug_string(), "Some(5)");
Source§

impl<T> ToLowerHexString for T
where T: LowerHex,

Source§

fn to_lower_hex_string(&self) -> String

Returns the String produced by Ts LowerHex implementation.

§Examples
use malachite_base::strings::ToLowerHexString;

assert_eq!(50u64.to_lower_hex_string(), "32");
assert_eq!((-100i16).to_lower_hex_string(), "ff9c");
§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T> ToString for T
where T: Display + ?Sized,

§

fn to_string(&self) -> String

Converts the given value to a String. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T, U> WrappingInto<U> for T
where U: WrappingFrom<T>,

Source§

fn wrapping_into(self) -> U

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,