Struct num256::int256::Int256 [−][src]
pub struct Int256(pub BigInt);
Methods
impl Int256
[src]
impl Int256
Methods from Deref<Target = BigInt>
pub fn to_bytes_be(&self) -> (Sign, Vec<u8>)
[src]
pub fn to_bytes_be(&self) -> (Sign, Vec<u8>)
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]));
pub fn to_bytes_le(&self) -> (Sign, Vec<u8>)
[src]
pub fn to_bytes_le(&self) -> (Sign, Vec<u8>)
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]));
pub fn to_signed_bytes_be(&self) -> Vec<u8>
[src]
pub fn to_signed_bytes_be(&self) -> 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]);
pub fn to_signed_bytes_le(&self) -> Vec<u8>
[src]
pub fn to_signed_bytes_le(&self) -> 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]);
pub fn to_str_radix(&self, radix: u32) -> String
[src]
pub fn to_str_radix(&self, radix: u32) -> String
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");
pub fn to_radix_be(&self, radix: u32) -> (Sign, Vec<u8>)
[src]
pub fn to_radix_be(&self, radix: u32) -> (Sign, Vec<u8>)
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
pub fn to_radix_le(&self, radix: u32) -> (Sign, Vec<u8>)
[src]
pub fn to_radix_le(&self, radix: u32) -> (Sign, Vec<u8>)
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)
pub fn sign(&self) -> Sign
[src]
pub fn sign(&self) -> Sign
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);
pub fn bits(&self) -> usize
[src]
pub fn bits(&self) -> usize
Determines the fewest bits necessary to express the BigInt
,
not including the sign.
pub fn to_biguint(&self) -> Option<BigUint>
[src]
pub fn to_biguint(&self) -> Option<BigUint>
Converts this BigInt
into a BigUint
, if it's not negative.
pub fn checked_add(&self, v: &BigInt) -> Option<BigInt>
[src]
pub fn checked_add(&self, v: &BigInt) -> Option<BigInt>
pub fn checked_sub(&self, v: &BigInt) -> Option<BigInt>
[src]
pub fn checked_sub(&self, v: &BigInt) -> Option<BigInt>
pub fn checked_mul(&self, v: &BigInt) -> Option<BigInt>
[src]
pub fn checked_mul(&self, v: &BigInt) -> Option<BigInt>
pub fn checked_div(&self, v: &BigInt) -> Option<BigInt>
[src]
pub fn checked_div(&self, v: &BigInt) -> Option<BigInt>
pub fn modpow(&self, exponent: &BigInt, modulus: &BigInt) -> BigInt
[src]
pub fn modpow(&self, exponent: &BigInt, modulus: &BigInt) -> BigInt
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]
impl Clone for Int256
fn clone(&self) -> Int256
[src]
fn clone(&self) -> Int256
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl PartialEq for Int256
[src]
impl PartialEq for Int256
fn eq(&self, other: &Int256) -> bool
[src]
fn eq(&self, other: &Int256) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Int256) -> bool
[src]
fn ne(&self, other: &Int256) -> bool
This method tests for !=
.
impl Eq for Int256
[src]
impl Eq for Int256
impl PartialOrd for Int256
[src]
impl PartialOrd for Int256
fn partial_cmp(&self, other: &Int256) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Int256) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Int256) -> bool
[src]
fn lt(&self, other: &Int256) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Int256) -> bool
[src]
fn le(&self, other: &Int256) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Int256) -> bool
[src]
fn gt(&self, other: &Int256) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Int256) -> bool
[src]
fn ge(&self, other: &Int256) -> bool
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]
impl Ord for Int256
fn cmp(&self, other: &Int256) -> Ordering
[src]
fn cmp(&self, other: &Int256) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl Deref for Int256
[src]
impl Deref for Int256
type Target = BigInt
The resulting type after dereferencing.
fn deref(&self) -> &BigInt
[src]
fn deref(&self) -> &BigInt
Dereferences the value.
impl Neg for Int256
[src]
impl Neg for Int256
type Output = Int256
The resulting type after applying the -
operator.
fn neg(self) -> Self::Output
[src]
fn neg(self) -> Self::Output
Performs the unary -
operation.
impl From<Uint256> for Int256
[src]
impl From<Uint256> for Int256
impl From<i8> for Int256
[src]
impl From<i8> for Int256
impl From<i16> for Int256
[src]
impl From<i16> for Int256
impl From<i32> for Int256
[src]
impl From<i32> for Int256
impl From<i64> for Int256
[src]
impl From<i64> for Int256
impl From<isize> for Int256
[src]
impl From<isize> for Int256
impl From<u8> for Int256
[src]
impl From<u8> for Int256
impl From<u16> for Int256
[src]
impl From<u16> for Int256
impl From<u32> for Int256
[src]
impl From<u32> for Int256
impl From<u64> for Int256
[src]
impl From<u64> for Int256
impl From<usize> for Int256
[src]
impl From<usize> for Int256
impl Into<i8> for Int256
[src]
impl Into<i8> for Int256
impl Into<i16> for Int256
[src]
impl Into<i16> for Int256
impl Into<i32> for Int256
[src]
impl Into<i32> for Int256
impl Into<i64> for Int256
[src]
impl Into<i64> for Int256
impl Into<isize> for Int256
[src]
impl Into<isize> for Int256
impl Into<u8> for Int256
[src]
impl Into<u8> for Int256
impl Into<u16> for Int256
[src]
impl Into<u16> for Int256
impl Into<u32> for Int256
[src]
impl Into<u32> for Int256
impl Into<u64> for Int256
[src]
impl Into<u64> for Int256
impl Into<usize> for Int256
[src]
impl Into<usize> for Int256
impl<'a> From<&'a Int256> for Int256
[src]
impl<'a> From<&'a Int256> for Int256
impl<'a> From<&'a Uint256> for Int256
[src]
impl<'a> From<&'a Uint256> for Int256
impl Display for Int256
[src]
impl Display for Int256
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Debug for Int256
[src]
impl Debug for Int256
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Serialize for Int256
[src]
impl Serialize for Int256
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
[src]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<'de> Deserialize<'de> for Int256
[src]
impl<'de> Deserialize<'de> for Int256
fn deserialize<D>(deserializer: D) -> Result<Int256, D::Error> where
D: Deserializer<'de>,
[src]
fn deserialize<D>(deserializer: D) -> Result<Int256, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<T> Add<T> for Int256 where
T: Into<Int256>,
[src]
impl<T> Add<T> for Int256 where
T: Into<Int256>,
type Output = Int256
The resulting type after applying the +
operator.
fn add(self, v: T) -> Int256
[src]
fn add(self, v: T) -> Int256
Performs the +
operation.
impl<T> AddAssign<T> for Int256 where
T: Into<Int256>,
[src]
impl<T> AddAssign<T> for Int256 where
T: Into<Int256>,
fn add_assign(&mut self, v: T)
[src]
fn add_assign(&mut self, v: T)
Performs the +=
operation.
impl CheckedAdd for Int256
[src]
impl CheckedAdd for Int256
fn checked_add(&self, v: &Int256) -> Option<Int256>
[src]
fn checked_add(&self, v: &Int256) -> Option<Int256>
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]
impl<T> Sub<T> for Int256 where
T: Into<Int256>,
type Output = Int256
The resulting type after applying the -
operator.
fn sub(self, v: T) -> Int256
[src]
fn sub(self, v: T) -> Int256
Performs the -
operation.
impl<T> SubAssign<T> for Int256 where
T: Into<Int256>,
[src]
impl<T> SubAssign<T> for Int256 where
T: Into<Int256>,
fn sub_assign(&mut self, v: T)
[src]
fn sub_assign(&mut self, v: T)
Performs the -=
operation.
impl CheckedSub for Int256
[src]
impl CheckedSub for Int256
fn checked_sub(&self, v: &Int256) -> Option<Int256>
[src]
fn checked_sub(&self, v: &Int256) -> Option<Int256>
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]
impl<T> Mul<T> for Int256 where
T: Into<Int256>,
type Output = Int256
The resulting type after applying the *
operator.
fn mul(self, v: T) -> Int256
[src]
fn mul(self, v: T) -> Int256
Performs the *
operation.
impl<T> MulAssign<T> for Int256 where
T: Into<Int256>,
[src]
impl<T> MulAssign<T> for Int256 where
T: Into<Int256>,
fn mul_assign(&mut self, v: T)
[src]
fn mul_assign(&mut self, v: T)
Performs the *=
operation.
impl CheckedMul for Int256
[src]
impl CheckedMul for Int256
fn checked_mul(&self, v: &Int256) -> Option<Int256>
[src]
fn checked_mul(&self, v: &Int256) -> Option<Int256>
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]
impl<T> DivAssign<T> for Int256 where
T: Into<Int256>,
fn div_assign(&mut self, v: T)
[src]
fn div_assign(&mut self, v: T)
Performs the /=
operation.
impl<T> Div<T> for Int256 where
T: Into<Int256>,
[src]
impl<T> Div<T> for Int256 where
T: Into<Int256>,
type Output = Int256
The resulting type after applying the /
operator.
fn div(self, v: T) -> Int256
[src]
fn div(self, v: T) -> Int256
Performs the /
operation.
impl CheckedDiv for Int256
[src]
impl CheckedDiv for Int256
fn checked_div(&self, v: &Int256) -> Option<Int256>
[src]
fn checked_div(&self, v: &Int256) -> Option<Int256>
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]
impl From<Int256> for Uint256