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

pub struct Int256(pub BigInt);

Methods

impl Int256
[src]

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]));

Important traits for Vec<u8>

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]);

Important traits for Vec<u8>

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.

Trait Implementations

impl Clone for Int256
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl PartialEq for Int256
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Eq for Int256
[src]

impl PartialOrd for Int256
[src]

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

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Ord for Int256
[src]

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

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

impl Deref for Int256
[src]

The resulting type after dereferencing.

Dereferences the value.

impl Neg for Int256
[src]

The resulting type after applying the - operator.

Performs the unary - operation.

impl From<Uint256> for Int256
[src]

Performs the conversion.

impl From<i8> for Int256
[src]

Performs the conversion.

impl From<i16> for Int256
[src]

Performs the conversion.

impl From<i32> for Int256
[src]

Performs the conversion.

impl From<i64> for Int256
[src]

Performs the conversion.

impl From<isize> for Int256
[src]

Performs the conversion.

impl From<u8> for Int256
[src]

Performs the conversion.

impl From<u16> for Int256
[src]

Performs the conversion.

impl From<u32> for Int256
[src]

Performs the conversion.

impl From<u64> for Int256
[src]

Performs the conversion.

impl From<usize> for Int256
[src]

Performs the conversion.

impl Into<i8> for Int256
[src]

Performs the conversion.

impl Into<i16> for Int256
[src]

Performs the conversion.

impl Into<i32> for Int256
[src]

Performs the conversion.

impl Into<i64> for Int256
[src]

Performs the conversion.

impl Into<isize> for Int256
[src]

Performs the conversion.

impl Into<u8> for Int256
[src]

Performs the conversion.

impl Into<u16> for Int256
[src]

Performs the conversion.

impl Into<u32> for Int256
[src]

Performs the conversion.

impl Into<u64> for Int256
[src]

Performs the conversion.

impl Into<usize> for Int256
[src]

Performs the conversion.

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

Performs the conversion.

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

Performs the conversion.

impl Display for Int256
[src]

Formats the value using the given formatter. Read more

impl Debug for Int256
[src]

Formats the value using the given formatter. Read more

impl Serialize for Int256
[src]

Serialize this value into the given Serde serializer. Read more

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

Deserialize this value from the given Serde deserializer. Read more

impl<T> Add<T> for Int256 where
    T: Into<Int256>, 
[src]

The resulting type after applying the + operator.

Performs the + operation.

impl<T> AddAssign<T> for Int256 where
    T: Into<Int256>, 
[src]

Performs the += operation.

impl CheckedAdd for Int256
[src]

Adds two numbers, checking for overflow. If overflow happens, None is returned. Read more

impl<T> Sub<T> for Int256 where
    T: Into<Int256>, 
[src]

The resulting type after applying the - operator.

Performs the - operation.

impl<T> SubAssign<T> for Int256 where
    T: Into<Int256>, 
[src]

Performs the -= operation.

impl CheckedSub for Int256
[src]

Subtracts two numbers, checking for underflow. If underflow happens, None is returned. Read more

impl<T> Mul<T> for Int256 where
    T: Into<Int256>, 
[src]

The resulting type after applying the * operator.

Performs the * operation.

impl<T> MulAssign<T> for Int256 where
    T: Into<Int256>, 
[src]

Performs the *= operation.

impl CheckedMul for Int256
[src]

Multiplies two numbers, checking for underflow or overflow. If underflow or overflow happens, None is returned. Read more

impl<T> DivAssign<T> for Int256 where
    T: Into<Int256>, 
[src]

Performs the /= operation.

impl<T> Div<T> for Int256 where
    T: Into<Int256>, 
[src]

The resulting type after applying the / operator.

Performs the / operation.

impl CheckedDiv for Int256
[src]

Divides two numbers, checking for underflow, overflow and division by zero. If any of that happens, None is returned. Read more

impl From<Int256> for Uint256
[src]

Performs the conversion.

Auto Trait Implementations

impl Send for Int256

impl Sync for Int256