A Big integer (signed version: BigInt, unsigned version: BigUint).

A BigUint is represented as an array of BigDigits. A BigInt is a combination of BigUint and Sign.

Type BigDigit

type BigDigit = u32

A BigDigit is a BigUint's composing element.

A BigDigit is half the size of machine word size.

Enum Sign

A Sign is a BigInt's composing element.

Variants

Struct BigInt

pub struct BigInt {
    priv sign: Sign,
    priv data: BigUint,
}

A big signed integer type.

Struct BigUint

pub struct BigUint {
    priv data: ~[BigDigit],
}

A big unsigned integer type.

A BigUint-typed value BigUint { data: @[a, b, c] } represents a number (a + b * BigDigit::base + c * BigDigit::base^2).

Implementation of ::std::clone::Clone for BigUint

Automatically derived.

Method clone

fn clone(&self) -> BigUint

Implementation of Eq for BigUint

Method eq

fn eq(&self, other: &BigUint) -> bool

Method ne

fn ne(&self, other: &BigUint) -> bool

Implementation of TotalEq for BigUint

Method equals

fn equals(&self, other: &BigUint) -> bool

Implementation of Ord for BigUint

Method lt

fn lt(&self, other: &BigUint) -> bool

Method le

fn le(&self, other: &BigUint) -> bool

Method ge

fn ge(&self, other: &BigUint) -> bool

Method gt

fn gt(&self, other: &BigUint) -> bool

Implementation of TotalOrd for BigUint

Method cmp

fn cmp(&self, other: &BigUint) -> Ordering

Implementation of ToStr for BigUint

Method to_str

fn to_str(&self) -> ~str

Implementation of FromStr for BigUint

Method from_str

fn from_str(s: &str) -> Option<BigUint>

Implementation of Num for BigUint

Implementation of Orderable for BigUint

Method min

fn min(&self, other: &BigUint) -> BigUint

Method max

fn max(&self, other: &BigUint) -> BigUint

Method clamp

fn clamp(&self, mn: &BigUint, mx: &BigUint) -> BigUint

Implementation of Shl<uint, BigUint> for BigUint

Method shl

fn shl(&self, rhs: &uint) -> BigUint

Implementation of Shr<uint, BigUint> for BigUint

Method shr

fn shr(&self, rhs: &uint) -> BigUint

Implementation of Zero for BigUint

Method zero

fn zero() -> BigUint

Method is_zero

fn is_zero(&self) -> bool

Implementation of One for BigUint

Method one

fn one() -> BigUint

Implementation of Unsigned for BigUint

Implementation of Add<BigUint, BigUint> for BigUint

Method add

fn add(&self, other: &BigUint) -> BigUint

Implementation of Sub<BigUint, BigUint> for BigUint

Method sub

fn sub(&self, other: &BigUint) -> BigUint

Implementation of Mul<BigUint, BigUint> for BigUint

Method mul

fn mul(&self, other: &BigUint) -> BigUint

Implementation of Div<BigUint, BigUint> for BigUint

Method div

fn div(&self, other: &BigUint) -> BigUint

Implementation of Rem<BigUint, BigUint> for BigUint

Method rem

fn rem(&self, other: &BigUint) -> BigUint

Implementation of Neg<BigUint> for BigUint

Method neg

fn neg(&self) -> BigUint

Implementation of Integer for BigUint

Method div_rem

fn div_rem(&self, other: &BigUint) -> (BigUint, BigUint)

Method div_floor

fn div_floor(&self, other: &BigUint) -> BigUint

Method mod_floor

fn mod_floor(&self, other: &BigUint) -> BigUint

Method div_mod_floor

fn div_mod_floor(&self, other: &BigUint) -> (BigUint, BigUint)

Method gcd

fn gcd(&self, other: &BigUint) -> BigUint

Calculates the Greatest Common Divisor (GCD) of the number and other

The result is always positive

Method lcm

fn lcm(&self, other: &BigUint) -> BigUint

Calculates the Lowest Common Multiple (LCM) of the number and other

Method is_multiple_of

fn is_multiple_of(&self, other: &BigUint) -> bool

Returns true if the number can be divided by other without leaving a remainder

Method is_even

fn is_even(&self) -> bool

Returns true if the number is divisible by 2

Method is_odd

fn is_odd(&self) -> bool

Returns true if the number is not divisible by 2

Implementation of IntConvertible for BigUint

Method to_int

fn to_int(&self) -> int

Method from_int

fn from_int(n: int) -> BigUint

Implementation of ToStrRadix for BigUint

Method to_str_radix

fn to_str_radix(&self, radix: uint) -> ~str

Implementation of FromStrRadix for BigUint

Method from_str_radix

fn from_str_radix(s: &str, radix: uint) -> Option<BigUint>

Creates and initializes an BigUint.

Implementation for BigUint

Method new

fn new(v: ~[BigDigit]) -> BigUint

Creates and initializes an BigUint.

Method from_uint

fn from_uint(n: uint) -> BigUint

Creates and initializes an BigUint.

Method from_slice

fn from_slice(slice: &[BigDigit]) -> BigUint

Creates and initializes an BigUint.

Method parse_bytes

fn parse_bytes(buf: &[u8], radix: uint) -> Option<BigUint>

Creates and initializes an BigUint.

Method to_uint

fn to_uint(&self) -> uint

Converts this big integer into a uint, returning the uint::max_value if it's too large to fit in a uint.

Implementation of ::std::cmp::Eq for Sign

Automatically derived.

Method eq

fn eq(&self, __arg_0: &Sign) -> ::bool

Method ne

fn ne(&self, __arg_0: &Sign) -> ::bool

Implementation of ::std::clone::Clone for Sign

Automatically derived.

Method clone

fn clone(&self) -> Sign

Implementation of Ord for Sign

Method lt

fn lt(&self, other: &Sign) -> bool

Method le

fn le(&self, other: &Sign) -> bool

Method ge

fn ge(&self, other: &Sign) -> bool

Method gt

fn gt(&self, other: &Sign) -> bool

Implementation of TotalOrd for Sign

Method cmp

fn cmp(&self, other: &Sign) -> Ordering

Implementation of Neg<Sign> for Sign

Method neg

fn neg(&self) -> Sign

Negate Sign value.

Implementation of ::std::clone::Clone for BigInt

Automatically derived.

Method clone

fn clone(&self) -> BigInt

Implementation of Eq for BigInt

Method eq

fn eq(&self, other: &BigInt) -> bool

Method ne

fn ne(&self, other: &BigInt) -> bool

Implementation of TotalEq for BigInt

Method equals

fn equals(&self, other: &BigInt) -> bool

Implementation of Ord for BigInt

Method lt

fn lt(&self, other: &BigInt) -> bool

Method le

fn le(&self, other: &BigInt) -> bool

Method ge

fn ge(&self, other: &BigInt) -> bool

Method gt

fn gt(&self, other: &BigInt) -> bool

Implementation of TotalOrd for BigInt

Method cmp

fn cmp(&self, other: &BigInt) -> Ordering

Implementation of ToStr for BigInt

Method to_str

fn to_str(&self) -> ~str

Implementation of FromStr for BigInt

Method from_str

fn from_str(s: &str) -> Option<BigInt>

Implementation of Num for BigInt

Implementation of Orderable for BigInt

Method min

fn min(&self, other: &BigInt) -> BigInt

Method max

fn max(&self, other: &BigInt) -> BigInt

Method clamp

fn clamp(&self, mn: &BigInt, mx: &BigInt) -> BigInt

Implementation of Shl<uint, BigInt> for BigInt

Method shl

fn shl(&self, rhs: &uint) -> BigInt

Implementation of Shr<uint, BigInt> for BigInt

Method shr

fn shr(&self, rhs: &uint) -> BigInt

Implementation of Zero for BigInt

Method zero

fn zero() -> BigInt

Method is_zero

fn is_zero(&self) -> bool

Implementation of One for BigInt

Method one

fn one() -> BigInt

Implementation of Signed for BigInt

Method abs

fn abs(&self) -> BigInt

Method abs_sub

fn abs_sub(&self, other: &BigInt) -> BigInt

Method signum

fn signum(&self) -> BigInt

Method is_positive

fn is_positive(&self) -> bool

Method is_negative

fn is_negative(&self) -> bool

Implementation of Add<BigInt, BigInt> for BigInt

Method add

fn add(&self, other: &BigInt) -> BigInt

Implementation of Sub<BigInt, BigInt> for BigInt

Method sub

fn sub(&self, other: &BigInt) -> BigInt

Implementation of Mul<BigInt, BigInt> for BigInt

Method mul

fn mul(&self, other: &BigInt) -> BigInt

Implementation of Div<BigInt, BigInt> for BigInt

Method div

fn div(&self, other: &BigInt) -> BigInt

Implementation of Rem<BigInt, BigInt> for BigInt

Method rem

fn rem(&self, other: &BigInt) -> BigInt

Implementation of Neg<BigInt> for BigInt

Method neg

fn neg(&self) -> BigInt

Implementation of Integer for BigInt

Method div_rem

fn div_rem(&self, other: &BigInt) -> (BigInt, BigInt)

Method div_floor

fn div_floor(&self, other: &BigInt) -> BigInt

Method mod_floor

fn mod_floor(&self, other: &BigInt) -> BigInt

Method div_mod_floor

fn div_mod_floor(&self, other: &BigInt) -> (BigInt, BigInt)

Method gcd

fn gcd(&self, other: &BigInt) -> BigInt

Calculates the Greatest Common Divisor (GCD) of the number and other

The result is always positive

Method lcm

fn lcm(&self, other: &BigInt) -> BigInt

Calculates the Lowest Common Multiple (LCM) of the number and other

Method is_multiple_of

fn is_multiple_of(&self, other: &BigInt) -> bool

Returns true if the number can be divided by other without leaving a remainder

Method is_even

fn is_even(&self) -> bool

Returns true if the number is divisible by 2

Method is_odd

fn is_odd(&self) -> bool

Returns true if the number is not divisible by 2

Implementation of IntConvertible for BigInt

Method to_int

fn to_int(&self) -> int

Method from_int

fn from_int(n: int) -> BigInt

Implementation of ToStrRadix for BigInt

Method to_str_radix

fn to_str_radix(&self, radix: uint) -> ~str

Implementation of FromStrRadix for BigInt

Method from_str_radix

fn from_str_radix(s: &str, radix: uint) -> Option<BigInt>

Creates and initializes an BigInt.

Implementation for BigInt

Method new

fn new(sign: Sign, v: ~[BigDigit]) -> BigInt

Creates and initializes an BigInt.

Method from_biguint

fn from_biguint(sign: Sign, data: BigUint) -> BigInt

Creates and initializes an BigInt.

Method from_uint

fn from_uint(n: uint) -> BigInt

Creates and initializes an BigInt.

Method from_slice

fn from_slice(sign: Sign, slice: &[BigDigit]) -> BigInt

Creates and initializes an BigInt.

Method parse_bytes

fn parse_bytes(buf: &[u8], radix: uint) -> Option<BigInt>

Creates and initializes an BigInt.

Method to_uint

fn to_uint(&self) -> uint