[][src]Struct num256::int256::Int256

pub struct Int256(pub BigInt);

Methods

impl Int256
[src]

Checked conversion to Uint256

Methods from Deref<Target = BigInt>

Returns the sign and the byte representation of the BigInt in big-endian byte order.

Examples

use num_bigint::{ToBigInt, Sign};

let i = -1125.to_bigint().unwrap();
assert_eq!(i.to_bytes_be(), (Sign::Minus, vec![4, 101]));

Returns the sign and the byte representation of the BigInt in little-endian byte order.

Examples

use num_bigint::{ToBigInt, Sign};

let i = -1125.to_bigint().unwrap();
assert_eq!(i.to_bytes_le(), (Sign::Minus, vec![101, 4]));

Returns the two's complement byte representation of the BigInt in big-endian byte order.

Examples

use num_bigint::ToBigInt;

let i = -1125.to_bigint().unwrap();
assert_eq!(i.to_signed_bytes_be(), vec![251, 155]);

Returns the two's complement byte representation of the BigInt in little-endian byte order.

Examples

use num_bigint::ToBigInt;

let i = -1125.to_bigint().unwrap();
assert_eq!(i.to_signed_bytes_le(), vec![155, 251]);

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

Examples

use num_bigint::BigInt;

let i = BigInt::parse_bytes(b"ff", 16).unwrap();
assert_eq!(i.to_str_radix(16), "ff");

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::{BigInt, Sign};

assert_eq!(BigInt::from(-0xFFFFi64).to_radix_be(159),
           (Sign::Minus, vec![2, 94, 27]));
// 0xFFFF = 65535 = 2*(159^2) + 94*159 + 27

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::{BigInt, Sign};

assert_eq!(BigInt::from(-0xFFFFi64).to_radix_le(159),
           (Sign::Minus, vec![27, 94, 2]));
// 0xFFFF = 65535 = 27 + 94*159 + 2*(159^2)

Returns the sign of the BigInt as a Sign.

Examples

use num_bigint::{ToBigInt, Sign};

assert_eq!(ToBigInt::to_bigint(&1234).unwrap().sign(), Sign::Plus);
assert_eq!(ToBigInt::to_bigint(&-4321).unwrap().sign(), Sign::Minus);
assert_eq!(ToBigInt::to_bigint(&0).unwrap().sign(), Sign::NoSign);

Determines the fewest bits necessary to express the BigInt, not including the sign.

Converts this BigInt into a BigUint, if it's not negative.

Returns (self ^ exponent) mod modulus

Note that this rounds like mod_floor, not like the % operator, which makes a difference when given a negative self or modulus. The result will be in the interval [0, modulus) for modulus > 0, or in the interval (modulus, 0] for modulus < 0

Panics if the exponent is negative or the modulus is zero.

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

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

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

Trait Implementations

impl Clone for Int256
[src]

Performs copy-assignment from source. Read more

impl From<i8> for Int256
[src]

impl From<i16> for Int256
[src]

impl From<i32> for Int256
[src]

impl From<i64> for Int256
[src]

impl From<i128> for Int256
[src]

impl From<isize> for Int256
[src]

impl<'a> From<&'a Int256> for Int256
[src]

impl Eq for Int256
[src]

impl PartialOrd<Int256> for Int256
[src]

impl Default for Int256
[src]

impl PartialEq<Int256> for Int256
[src]

impl Ord for Int256
[src]

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

impl Debug for Int256
[src]

impl Display for Int256
[src]

impl Add<Int256> for Int256
[src]

The resulting type after applying the + operator.

impl Sub<Int256> for Int256
[src]

The resulting type after applying the - operator.

impl Mul<Int256> for Int256
[src]

The resulting type after applying the * operator.

impl Div<Int256> for Int256
[src]

The resulting type after applying the / operator.

impl Neg for Int256
[src]

The resulting type after applying the - operator.

impl AddAssign<Int256> for Int256
[src]

impl SubAssign<Int256> for Int256
[src]

impl MulAssign<Int256> for Int256
[src]

impl DivAssign<Int256> for Int256
[src]

impl Deref for Int256
[src]

The resulting type after dereferencing.

impl Hash for Int256
[src]

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

impl CheckedMul for Int256
[src]

impl ToPrimitive for Int256
[src]

impl Bounded for Int256
[src]

impl CheckedDiv for Int256
[src]

impl CheckedSub for Int256
[src]

impl CheckedAdd for Int256
[src]

impl FromPrimitive for Int256
[src]

impl Zero for Int256
[src]

impl Serialize for Int256
[src]

impl<'de> Deserialize<'de> for Int256
[src]

Auto Trait Implementations

impl Send for Int256

impl Sync for Int256

Blanket Implementations

impl<T> From for T
[src]

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

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

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

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

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

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

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

The type returned in the event of a conversion error.

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

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