bigint::uint

Struct U512

Source
#[repr(C)]
pub struct U512(pub [u64; 8]);
Expand description

Little-endian large integer type

Tuple Fields§

§0: [u64; 8]

Implementations§

Source§

impl U512

Source

pub const MAX: U512 = _

Source

pub fn from_dec_str(value: &str) -> Result<Self, FromDecStrErr>

Convert from a decimal string.

Source

pub fn low_u32(&self) -> u32

Conversion to u32

Source

pub fn low_u64(&self) -> u64

Conversion to u64

Source

pub fn as_u32(&self) -> u32

Conversion to u32 with overflow checking

§Panics

Panics if the number is larger than 2^32.

Source

pub fn as_u64(&self) -> u64

Conversion to u64 with overflow checking

§Panics

Panics if the number is larger than 2^64.

Source

pub fn is_zero(&self) -> bool

Whether this is zero.

Source

pub fn bits(&self) -> usize

Return the least number of bits needed to represent the number

Source

pub fn bit(&self, index: usize) -> bool

Return if specific bit is set.

§Panics

Panics if index exceeds the bit width of the number.

Source

pub fn leading_zeros(&self) -> u32

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

Source

pub fn trailing_zeros(&self) -> u32

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

Source

pub fn byte(&self, index: usize) -> u8

Return specific byte.

§Panics

Panics if index exceeds the byte width of the number.

Source

pub fn to_big_endian(&self, bytes: &mut [u8])

Write to the slice in big-endian format.

Source

pub fn to_little_endian(&self, bytes: &mut [u8])

Write to the slice in little-endian format.

Source

pub fn exp10(n: usize) -> Self

Create 10**n as this type.

§Panics

Panics if the result overflows the type.

Source

pub fn zero() -> Self

Zero (additive identity) of this type.

Source

pub fn one() -> Self

One (multiplicative identity) of this type.

Source

pub fn max_value() -> Self

The maximum value which can be inhabited by this type.

Source

pub fn pow(self, expon: Self) -> Self

Fast exponentation by squaring https://en.wikipedia.org/wiki/Exponentiation_by_squaring

§Panics

Panics if the result overflows the type.

Source

pub fn overflowing_pow(self, expon: Self) -> (Self, bool)

Fast exponentation by squaring https://en.wikipedia.org/wiki/Exponentiation_by_squaring

Source

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

Optimized instructions

Source

pub fn saturating_add(self, other: U512) -> U512

Addition which saturates at the maximum value.

Source

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

Subtraction which underflows and returns a flag if it does.

Source

pub fn saturating_sub(self, other: U512) -> U512

Subtraction which saturates at zero.

Source

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

Multiply with overflow, returning a flag if it does.

Source

pub fn saturating_mul(self, other: U512) -> U512

Multiplication which saturates at the maximum value..

Source

pub fn overflowing_div(self, other: U512) -> (U512, bool)

Division with overflow

Source

pub fn overflowing_rem(self, other: U512) -> (U512, bool)

Modulus with overflow.

Source

pub fn overflowing_neg(self) -> (U512, bool)

Negation with overflow.

Source

pub fn from_big_endian(slice: &[u8]) -> Self

Converts from big endian representation bytes in memory Can also be used as (&slice).into(), as it is default From slice implementation for U256

Source

pub fn from_little_endian(slice: &[u8]) -> Self

Converts from little endian representation bytes in memory

Trait Implementations§

Source§

impl Add for U512

Source§

type Output = U512

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl BitAnd for U512

Source§

type Output = U512

The resulting type after applying the & operator.
Source§

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

Performs the & operation. Read more
Source§

impl BitOr for U512

Source§

type Output = U512

The resulting type after applying the | operator.
Source§

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

Performs the | operation. Read more
Source§

impl BitXor for U512

Source§

type Output = U512

The resulting type after applying the ^ operator.
Source§

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

Performs the ^ operation. Read more
Source§

impl Clone for U512

Source§

fn clone(&self) -> U512

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for U512

Source§

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

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

impl Default for U512

Source§

fn default() -> Self

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

impl Display for U512

Source§

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

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

impl Div for U512

Source§

type Output = U512

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<'a> From<&'a [u8]> for U512

Source§

fn from(bytes: &[u8]) -> U512

Converts to this type from the input type.
Source§

impl<'a> From<&'a [u8; 64]> for U512

Source§

fn from(bytes: &[u8; 64]) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a U256> for U512

Source§

fn from(value: &'a U256) -> U512

Converts to this type from the input type.
Source§

impl<'a> From<&'a U512> for U256

Source§

fn from(value: &'a U512) -> U256

Converts to this type from the input type.
Source§

impl From<[u8; 64]> for U512

Source§

fn from(bytes: [u8; 64]) -> Self

Converts to this type from the input type.
Source§

impl From<U128> for U512

Source§

fn from(value: U128) -> U512

Converts to this type from the input type.
Source§

impl From<U256> for U512

Source§

fn from(value: U256) -> U512

Converts to this type from the input type.
Source§

impl From<U512> for [u8; 64]

Source§

fn from(number: U512) -> Self

Converts to this type from the input type.
Source§

impl From<U512> for U128

Source§

fn from(value: U512) -> U128

Converts to this type from the input type.
Source§

impl From<U512> for U256

Source§

fn from(value: U512) -> U256

Converts to this type from the input type.
Source§

impl From<i16> for U512

Source§

fn from(value: i16) -> U512

Converts to this type from the input type.
Source§

impl From<i32> for U512

Source§

fn from(value: i32) -> U512

Converts to this type from the input type.
Source§

impl From<i64> for U512

Source§

fn from(value: i64) -> U512

Converts to this type from the input type.
Source§

impl From<i8> for U512

Source§

fn from(value: i8) -> U512

Converts to this type from the input type.
Source§

impl From<isize> for U512

Source§

fn from(value: isize) -> U512

Converts to this type from the input type.
Source§

impl From<u16> for U512

Source§

fn from(value: u16) -> U512

Converts to this type from the input type.
Source§

impl From<u32> for U512

Source§

fn from(value: u32) -> U512

Converts to this type from the input type.
Source§

impl From<u64> for U512

Source§

fn from(value: u64) -> U512

Converts to this type from the input type.
Source§

impl From<u8> for U512

Source§

fn from(value: u8) -> U512

Converts to this type from the input type.
Source§

impl From<usize> for U512

Source§

fn from(value: usize) -> U512

Converts to this type from the input type.
Source§

impl Hash for U512

Source§

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

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

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 U512

Source§

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

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

impl Mul for U512

Source§

type Output = U512

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Not for U512

Source§

type Output = U512

The resulting type after applying the ! operator.
Source§

fn not(self) -> U512

Performs the unary ! operation. Read more
Source§

impl Ord for U512

Source§

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

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

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

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

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

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

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

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

impl PartialEq for U512

Source§

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

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

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 for U512

Source§

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

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

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

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

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 · Source§

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

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

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 Rem for U512

Source§

type Output = U512

The resulting type after applying the % operator.
Source§

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

Performs the % operation. Read more
Source§

impl Shl<usize> for U512

Source§

type Output = U512

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

fn shl(self, shift: usize) -> U512

Performs the << operation. Read more
Source§

impl Shr<usize> for U512

Source§

type Output = U512

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

fn shr(self, shift: usize) -> U512

Performs the >> operation. Read more
Source§

impl Sub for U512

Source§

type Output = U512

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Copy for U512

Source§

impl Eq for U512

Source§

impl StructuralPartialEq for U512

Auto Trait Implementations§

§

impl Freeze for U512

§

impl RefUnwindSafe for U512

§

impl Send for U512

§

impl Sync for U512

§

impl Unpin for U512

§

impl UnwindSafe for U512

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.