[−][src]Struct num256::uint256::Uint256

pub struct Uint256(pub BigUint);

Methods

impl Uint256[src]

pub fn to_int256(&self) -> Option<Int256>[src]

Converts value to a signed 256 bit integer

Methods from Deref<Target = BigUint>

pub fn to_bytes_be(&self) -> Vec<u8>[src]

Returns the byte representation of the BigUint in big-endian byte order.

Examples

use num_bigint::BigUint;

let i = BigUint::parse_bytes(b"1125", 10).unwrap();
assert_eq!(i.to_bytes_be(), vec![4, 101]);

pub fn to_bytes_le(&self) -> Vec<u8>[src]

Returns the byte representation of the BigUint in little-endian byte order.

Examples

use num_bigint::BigUint;

let i = BigUint::parse_bytes(b"1125", 10).unwrap();
assert_eq!(i.to_bytes_le(), vec![101, 4]);

pub fn to_str_radix(&self, radix: u32) -> String[src]

Returns the integer formatted as a string in the given radix. radix must be in the range 2...36.

Examples

use num_bigint::BigUint;

let i = BigUint::parse_bytes(b"ff", 16).unwrap();

pub fn to_radix_be(&self, radix: u32) -> Vec<u8>[src]

Returns the integer in the requested base in big-endian digit order. The output is not given in a human readable alphabet but as a zero based u8 number. radix must be in the range 2...256.

Examples

use num_bigint::BigUint;

vec![2, 94, 27]);
// 0xFFFF = 65535 = 2*(159^2) + 94*159 + 27

pub fn to_radix_le(&self, radix: u32) -> Vec<u8>[src]

Returns the integer in the requested base in little-endian digit order. The output is not given in a human readable alphabet but as a zero based u8 number. radix must be in the range 2...256.

Examples

use num_bigint::BigUint;

vec![27, 94, 2]);
// 0xFFFF = 65535 = 27 + 94*159 + 2*(159^2)

pub fn bits(&self) -> usize[src]

Determines the fewest bits necessary to express the BigUint.

pub fn modpow(&self, exponent: &BigUint, modulus: &BigUint) -> BigUint[src]

Returns (self ^ exponent) % modulus.

Panics if the modulus is zero.

pub fn sqrt(&self) -> BigUint[src]

Returns the truncated principal square root of self -- see Roots::sqrt

pub fn cbrt(&self) -> BigUint[src]

Returns the truncated principal cube root of self -- see Roots::cbrt.

pub fn nth_root(&self, n: u32) -> BigUint[src]

Returns the truncated principal nth root of self -- see Roots::nth_root.

Trait Implementations

impl Clone for Uint256[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Ord for Uint256[src]

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 Add<Uint256> for Uint256[src]

type Output = Uint256

The resulting type after applying the + operator.

impl Sub<Uint256> for Uint256[src]

type Output = Uint256

The resulting type after applying the - operator.

impl Mul<Uint256> for Uint256[src]

type Output = Uint256

The resulting type after applying the * operator.

impl Div<Uint256> for Uint256[src]

type Output = Uint256

The resulting type after applying the / operator.

impl Deref for Uint256[src]

type Target = BigUint

The resulting type after dereferencing.

impl Hash for Uint256[src]

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

Feeds a slice of this type into the given [Hasher]. Read more

impl FromStr for Uint256[src]

type Err = Error

The associated error which can be returned from parsing.

Blanket Implementations

impl<T, U> TryFrom for T where    T: From<U>, [src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T, U> TryInto for T where    U: TryFrom<T>, [src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.