Struct bignum::u256
[−]
[src]
pub struct u256 { /* fields omitted */ }Stack-allocated arbitrary-precision (up to certain limit) integer.
This is backed by a fixed-size array of given type ("digit").
While the array is not very large (normally some hundred bytes),
copying it recklessly may result in the performance hit.
Thus this is intentionally not Copy.
All operations available to bignums panic in the case of overflows. The caller is responsible to use large enough bignum types.
Methods
impl u256[src]
pub fn from_small(v: u32) -> u256[src]
Makes a bignum from one digit.
pub fn from_u64(v: u64) -> u256[src]
Makes a bignum from u64 value.
pub fn digits(&self) -> &[u32][src]
Returns the internal digits as a slice [a, b, c, ...] such that the numeric
value is a + b * 2^W + c * 2^(2W) + ... where W is the number of bits in
the digit type.
pub fn get_bit(&self, i: usize) -> u8[src]
Returns the i-th bit where bit 0 is the least significant one.
In other words, the bit with weight 2^i.
pub fn is_zero(&self) -> bool[src]
Returns true if the bignum is zero.
pub fn bit_length(&self) -> usize[src]
Returns the number of bits necessary to represent this value. Note that zero is considered to need 0 bits.
impl u256[src]
pub const MIN: u256
MIN: u256 = <u256>::min_value()
The smallest value that can be represented by this integer type.
pub const MAX: u256
MAX: u256 = <u256>::max_value()
The largest value that can be represented by this integer type.
pub const fn min_value() -> u256[src]
pub const fn max_value() -> u256[src]
pub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>[src]
pub fn count_ones(self) -> u32[src]
pub fn count_zeros(self) -> u32[src]
pub fn leading_zeros(self) -> u32[src]
pub fn trailing_zeros(self) -> u32[src]
pub fn rotate_left(self, n: u32) -> Self[src]
pub fn rotate_right(self, n: u32) -> Self[src]
pub fn swap_bytes(self) -> Self[src]
pub fn reverse_bits(self) -> Self[src]
pub fn from_be(x: Self) -> Self[src]
pub fn from_le(x: Self) -> Self[src]
pub fn to_be(self) -> Self[src]
pub fn to_le(self) -> Self[src]
Trait Implementations
impl Add<u32> for u256[src]
type Output = u256
The resulting type after applying the + operator.
fn add(self, other: u32) -> u256[src]
Performs the + operation.
impl AddAssign<u32> for u256[src]
fn add_assign(&mut self, other: u32)[src]
Performs the += operation.
impl Add<u256> for u256[src]
type Output = u256
The resulting type after applying the + operator.
fn add(self, other: u256) -> u256[src]
Performs the + operation.
impl AddAssign<u256> for u256[src]
fn add_assign(&mut self, other: u256)[src]
Performs the += operation.
impl Sub<u256> for u256[src]
type Output = u256
The resulting type after applying the - operator.
fn sub(self, other: u256) -> u256[src]
Performs the - operation.
impl SubAssign<u256> for u256[src]
fn sub_assign(&mut self, other: u256)[src]
Performs the -= operation.
impl Mul<u32> for u256[src]
type Output = u256
The resulting type after applying the * operator.
fn mul(self, rhs: u32) -> u256[src]
Performs the * operation.
impl Mul<u256> for u256[src]
type Output = u256
The resulting type after applying the * operator.
fn mul(self, rhs: u256) -> u256[src]
Performs the * operation.
impl MulAssign<u32> for u256[src]
fn mul_assign(&mut self, other: u32)[src]
Performs the *= operation.
impl MulAssign<u256> for u256[src]
fn mul_assign(&mut self, rhs: u256)[src]
Performs the *= operation.
impl Rem<u32> for u256[src]
type Output = u32
The resulting type after applying the % operator.
fn rem(self, other: u32) -> u32[src]
Performs the % operation.
impl RemAssign<u32> for u256[src]
fn rem_assign(&mut self, other: u32)[src]
Performs the %= operation.
impl Rem<u256> for u256[src]
type Output = u256
The resulting type after applying the % operator.
fn rem(self, other: u256) -> u256[src]
Performs the % operation.
impl RemAssign<u256> for u256[src]
fn rem_assign(&mut self, other: u256)[src]
Performs the %= operation.
impl Div<u32> for u256[src]
type Output = u256
The resulting type after applying the / operator.
fn div(self, other: u32) -> u256[src]
Performs the / operation.
impl DivAssign<u32> for u256[src]
fn div_assign(&mut self, other: u32)[src]
Performs the /= operation.
impl Div<u256> for u256[src]
type Output = u256
The resulting type after applying the / operator.
fn div(self, other: u256) -> u256[src]
Performs the / operation.
impl DivAssign<u256> for u256[src]
fn div_assign(&mut self, other: u256)[src]
Performs the /= operation.
impl Not for u256[src]
type Output = u256
The resulting type after applying the ! operator.
fn not(self) -> u256[src]
Performs the unary ! operation.
impl PartialEq for u256[src]
fn eq(&self, other: &u256) -> bool[src]
This method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
This method tests for !=.
impl Eq for u256[src]
impl PartialOrd for u256[src]
fn partial_cmp(&self, other: &u256) -> Option<Ordering>[src]
This method returns an ordering between self and other values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
This method tests less than (for self and other) and is used by the < operator. Read more
fn le(&self, other: &Rhs) -> bool1.0.0[src]
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
This method tests greater than (for self and other) and is used by the > operator. Read more
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl Ord for u256[src]
fn cmp(&self, other: &u256) -> Ordering[src]
This method returns an Ordering between self and other. Read more
fn max(self, other: Self) -> Self1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self1.21.0[src]
Compares and returns the minimum of two values. Read more
impl Display for u256[src]
fn fmt(&self, f: &mut Formatter) -> Result[src]
Formats the value using the given formatter. Read more
impl Debug for u256[src]
fn fmt(&self, f: &mut Formatter) -> Result[src]
Formats the value using the given formatter. Read more
impl LowerHex for u256[src]
impl UpperHex for u256[src]
impl Binary for u256[src]
impl Copy for u256[src]
impl Clone for u256[src]
fn clone(&self) -> u256[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more