Struct ibig::IBig[][src]

pub struct IBig { /* fields omitted */ }

Signed big integer.

Arbitrarily large signed integer.

Examples

let a = ibig!(a2a123bbb127779cccc123123ccc base 32);
let b = ibig!(-0x1231abcd4134);
let c = IBig::from_str_radix("a2a123bbb127779cccc123123ccc", 32)?;
let d = IBig::from_str_radix("-1231abcd4134", 16)?;
assert_eq!(a, c);
assert_eq!(b, d);

Implementations

impl IBig[src]

pub fn trailing_zeros(&self) -> Option<usize>[src]

Returns the number of trailing zeros in the two’s complement binary representation.

In other words, it is the smallest n such that 2 to the power of n divides the number.

For 0, it returns None.

Examples

assert_eq!(ibig!(17).trailing_zeros(), Some(0));
assert_eq!(ibig!(-48).trailing_zeros(), Some(4));
assert_eq!(ibig!(-0b101000000).trailing_zeros(), Some(6));
assert_eq!(ibig!(0).trailing_zeros(), None);

impl IBig[src]

pub fn to_f32(&self) -> f32[src]

Convert to f32.

Round to nearest, breaking ties to even last bit.

Examples

assert_eq!(ibig!(-134).to_f32(), -134.0f32);

pub fn to_f64(&self) -> f64[src]

Convert to f64.

Round to nearest, breaking ties to even last bit.

Examples

assert_eq!(ibig!(-134).to_f64(), -134.0f64);

impl IBig[src]

pub fn in_radix(&self, radix: u32) -> InRadix<'_>[src]

Representation in a given radix.

Panics

Panics if radix is not between 2 and 36 inclusive.

Examples

assert_eq!(format!("{}", ibig!(-83).in_radix(3)), "-10002");
assert_eq!(format!("{:010}", ibig!(-35).in_radix(36)), "-00000000z");

impl IBig[src]

pub fn from_str_radix(src: &str, radix: u32) -> Result<IBig, ParseError>[src]

Convert a string in a given base to IBig.

The string may contain a + or - prefix. Digits 10-35 are represented by a-z or A-Z.

Panics

Panics if radix is not between 2 and 36 inclusive.

Examples

assert_eq!(IBig::from_str_radix("-7ab", 32)?, ibig!(-7499));

pub fn from_str_with_radix_prefix(src: &str) -> Result<IBig, ParseError>[src]

Convert a string with an optional radix prefix to IBig.

src may contain an ‘+’ or - prefix after the radix prefix.

Allowed prefixes: 0b for binary, 0o for octal, 0x for hexadecimal.

Examples

assert_eq!(IBig::from_str_with_radix_prefix("+0o17")?, ibig!(0o17));
assert_eq!(IBig::from_str_with_radix_prefix("-0x1f")?, ibig!(-0x1f));

impl IBig[src]

pub fn pow(&self, exp: usize) -> IBig[src]

Raises self to the power of exp.

Example

assert_eq!(ibig!(-3).pow(3), ibig!(-27));

impl IBig[src]

pub fn signum(&self) -> IBig[src]

A number representing the sign of self.

  • -1 if the number is negative
  • 0 if the number is zero
  • 1 if the number is positive

Examples

assert_eq!(ibig!(-500).signum(), ibig!(-1));

Trait Implementations

impl Abs for IBig[src]

type Output = IBig

impl Abs for &IBig[src]

type Output = IBig

impl Add<&'_ IBig> for IBig[src]

type Output = IBig

The resulting type after applying the + operator.

impl Add<&'_ IBig> for &IBig[src]

type Output = IBig

The resulting type after applying the + operator.

impl Add<IBig> for IBig[src]

type Output = IBig

The resulting type after applying the + operator.

impl Add<IBig> for &IBig[src]

type Output = IBig

The resulting type after applying the + operator.

impl AddAssign<&'_ IBig> for IBig[src]

impl AddAssign<IBig> for IBig[src]

impl AndNot<&'_ IBig> for IBig[src]

type Output = IBig

impl AndNot<&'_ IBig> for &IBig[src]

type Output = IBig

impl AndNot<IBig> for IBig[src]

type Output = IBig

impl AndNot<IBig> for &IBig[src]

type Output = IBig

impl Binary for IBig[src]

impl BitAnd<&'_ IBig> for IBig[src]

type Output = IBig

The resulting type after applying the & operator.

impl BitAnd<&'_ IBig> for &IBig[src]

type Output = IBig

The resulting type after applying the & operator.

impl BitAnd<IBig> for IBig[src]

type Output = IBig

The resulting type after applying the & operator.

impl BitAnd<IBig> for &IBig[src]

type Output = IBig

The resulting type after applying the & operator.

impl BitAndAssign<&'_ IBig> for IBig[src]

impl BitAndAssign<IBig> for IBig[src]

impl BitOr<&'_ IBig> for IBig[src]

type Output = IBig

The resulting type after applying the | operator.

impl BitOr<&'_ IBig> for &IBig[src]

type Output = IBig

The resulting type after applying the | operator.

impl BitOr<IBig> for IBig[src]

type Output = IBig

The resulting type after applying the | operator.

impl BitOr<IBig> for &IBig[src]

type Output = IBig

The resulting type after applying the | operator.

impl BitOrAssign<&'_ IBig> for IBig[src]

impl BitOrAssign<IBig> for IBig[src]

impl BitXor<&'_ IBig> for IBig[src]

type Output = IBig

The resulting type after applying the ^ operator.

impl BitXor<&'_ IBig> for &IBig[src]

type Output = IBig

The resulting type after applying the ^ operator.

impl BitXor<IBig> for IBig[src]

type Output = IBig

The resulting type after applying the ^ operator.

impl BitXor<IBig> for &IBig[src]

type Output = IBig

The resulting type after applying the ^ operator.

impl BitXorAssign<&'_ IBig> for IBig[src]

impl BitXorAssign<IBig> for IBig[src]

impl Clone for IBig[src]

impl Debug for IBig[src]

impl Default for IBig[src]

fn default() -> IBig[src]

Default value: 0.

impl Display for IBig[src]

impl Div<&'_ IBig> for IBig[src]

type Output = IBig

The resulting type after applying the / operator.

impl Div<&'_ IBig> for &IBig[src]

type Output = IBig

The resulting type after applying the / operator.

impl Div<IBig> for IBig[src]

type Output = IBig

The resulting type after applying the / operator.

impl Div<IBig> for &IBig[src]

type Output = IBig

The resulting type after applying the / operator.

impl DivAssign<&'_ IBig> for IBig[src]

impl DivAssign<IBig> for IBig[src]

impl DivEuclid<&'_ IBig> for IBig[src]

type Output = IBig

impl DivEuclid<&'_ IBig> for &IBig[src]

type Output = IBig

impl DivEuclid<IBig> for IBig[src]

type Output = IBig

impl DivEuclid<IBig> for &IBig[src]

type Output = IBig

impl DivRem<&'_ IBig> for IBig[src]

type OutputDiv = IBig

type OutputRem = IBig

impl DivRem<&'_ IBig> for &IBig[src]

type OutputDiv = IBig

type OutputRem = IBig

impl DivRem<IBig> for IBig[src]

type OutputDiv = IBig

type OutputRem = IBig

impl DivRem<IBig> for &IBig[src]

type OutputDiv = IBig

type OutputRem = IBig

impl DivRemEuclid<&'_ IBig> for IBig[src]

impl DivRemEuclid<&'_ IBig> for &IBig[src]

impl DivRemEuclid<IBig> for IBig[src]

impl DivRemEuclid<IBig> for &IBig[src]

impl Eq for IBig[src]

impl From<&'_ UBig> for IBig[src]

impl From<UBig> for IBig[src]

impl From<bool> for IBig[src]

impl From<i128> for IBig[src]

impl From<i16> for IBig[src]

impl From<i32> for IBig[src]

impl From<i64> for IBig[src]

impl From<i8> for IBig[src]

impl From<isize> for IBig[src]

impl From<u128> for IBig[src]

impl From<u16> for IBig[src]

impl From<u32> for IBig[src]

impl From<u64> for IBig[src]

impl From<u8> for IBig[src]

impl From<usize> for IBig[src]

impl FromStr for IBig[src]

type Err = ParseError

The associated error which can be returned from parsing.

impl Hash for IBig[src]

impl IntoModulo for IBig[src]

impl IntoModulo for &IBig[src]

impl LowerHex for IBig[src]

impl Mul<&'_ IBig> for IBig[src]

type Output = IBig

The resulting type after applying the * operator.

impl Mul<&'_ IBig> for &IBig[src]

type Output = IBig

The resulting type after applying the * operator.

impl Mul<IBig> for IBig[src]

type Output = IBig

The resulting type after applying the * operator.

impl Mul<IBig> for &IBig[src]

type Output = IBig

The resulting type after applying the * operator.

impl MulAssign<&'_ IBig> for IBig[src]

impl MulAssign<IBig> for IBig[src]

impl Neg for IBig[src]

type Output = IBig

The resulting type after applying the - operator.

impl Neg for &IBig[src]

type Output = IBig

The resulting type after applying the - operator.

impl Not for IBig[src]

type Output = IBig

The resulting type after applying the ! operator.

impl Not for &IBig[src]

type Output = IBig

The resulting type after applying the ! operator.

impl Num for IBig[src]

type FromStrRadixErr = ParseError

impl Octal for IBig[src]

impl One for IBig[src]

impl Ord for IBig[src]

impl PartialEq<IBig> for IBig[src]

impl PartialOrd<IBig> for IBig[src]

impl Pow<usize> for IBig[src]

type Output = IBig

The result after applying the operator.

impl Pow<usize> for &IBig[src]

type Output = IBig

The result after applying the operator.

impl Rem<&'_ IBig> for IBig[src]

type Output = IBig

The resulting type after applying the % operator.

impl Rem<&'_ IBig> for &IBig[src]

type Output = IBig

The resulting type after applying the % operator.

impl Rem<IBig> for IBig[src]

type Output = IBig

The resulting type after applying the % operator.

impl Rem<IBig> for &IBig[src]

type Output = IBig

The resulting type after applying the % operator.

impl RemAssign<&'_ IBig> for IBig[src]

impl RemAssign<IBig> for IBig[src]

impl RemEuclid<&'_ IBig> for IBig[src]

type Output = IBig

impl RemEuclid<&'_ IBig> for &IBig[src]

type Output = IBig

impl RemEuclid<IBig> for IBig[src]

type Output = IBig

impl RemEuclid<IBig> for &IBig[src]

type Output = IBig

impl SampleUniform for IBig[src]

type Sampler = UniformIBig

The UniformSampler implementation supporting type X.

impl Shl<&'_ usize> for IBig[src]

type Output = IBig

The resulting type after applying the << operator.

impl Shl<&'_ usize> for &IBig[src]

type Output = IBig

The resulting type after applying the << operator.

impl Shl<usize> for IBig[src]

type Output = IBig

The resulting type after applying the << operator.

impl Shl<usize> for &IBig[src]

type Output = IBig

The resulting type after applying the << operator.

impl ShlAssign<&'_ usize> for IBig[src]

impl ShlAssign<usize> for IBig[src]

impl Shr<&'_ usize> for IBig[src]

type Output = IBig

The resulting type after applying the >> operator.

impl Shr<&'_ usize> for &IBig[src]

type Output = IBig

The resulting type after applying the >> operator.

impl Shr<usize> for IBig[src]

type Output = IBig

The resulting type after applying the >> operator.

impl Shr<usize> for &IBig[src]

type Output = IBig

The resulting type after applying the >> operator.

impl ShrAssign<&'_ usize> for IBig[src]

impl ShrAssign<usize> for IBig[src]

impl Signed for IBig[src]

impl StructuralEq for IBig[src]

impl StructuralPartialEq for IBig[src]

impl Sub<&'_ IBig> for IBig[src]

type Output = IBig

The resulting type after applying the - operator.

impl Sub<&'_ IBig> for &IBig[src]

type Output = IBig

The resulting type after applying the - operator.

impl Sub<IBig> for IBig[src]

type Output = IBig

The resulting type after applying the - operator.

impl Sub<IBig> for &IBig[src]

type Output = IBig

The resulting type after applying the - operator.

impl SubAssign<&'_ IBig> for IBig[src]

impl SubAssign<IBig> for IBig[src]

impl TryFrom<&'_ IBig> for UBig[src]

type Error = OutOfBoundsError

The type returned in the event of a conversion error.

impl TryFrom<IBig> for UBig[src]

type Error = OutOfBoundsError

The type returned in the event of a conversion error.

impl UnsignedAbs for IBig[src]

type Output = UBig

impl UnsignedAbs for &IBig[src]

type Output = UBig

impl UpperHex for IBig[src]

impl Zero for IBig[src]

Auto Trait Implementations

impl RefUnwindSafe for IBig

impl Send for IBig

impl Sync for IBig

impl Unpin for IBig

impl UnwindSafe for IBig

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

impl<T> NumAssign for T where
    T: Num + NumAssignOps<T>, 
[src]

impl<T, Rhs> NumAssignOps<Rhs> for T where
    T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>, 
[src]

impl<T> NumAssignRef for T where
    T: NumAssign + for<'r> NumAssignOps<&'r T>, 
[src]

impl<T, Rhs, Output> NumOps<Rhs, Output> for T where
    T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>, 
[src]

impl<T> NumRef for T where
    T: Num + for<'r> NumOps<&'r T, T>, 
[src]

impl<T, Base> RefNum<Base> for T where
    T: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base>, 
[src]

impl<Borrowed> SampleBorrow<Borrowed> for Borrowed where
    Borrowed: SampleUniform
[src]

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

type Owned = T

The resulting type after obtaining ownership.

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,