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.
BigDigit
- A BigDigit is a BigUint's composing element.Sign
- A Sign is a BigInt's composing element.BigInt
- A big signed integer type.BigUint
- A big unsigned integer type.of ::std::clone::Clone for BigUint
- Automatically derived.of Eq for BigUint
of TotalEq for BigUint
of Ord for BigUint
of TotalOrd for BigUint
of ToStr for BigUint
of FromStr for BigUint
of Num for BigUint
of Orderable for BigUint
of Shl<uint, BigUint> for BigUint
of Shr<uint, BigUint> for BigUint
of Zero for BigUint
of One for BigUint
of Unsigned for BigUint
of Add<BigUint, BigUint> for BigUint
of Sub<BigUint, BigUint> for BigUint
of Mul<BigUint, BigUint> for BigUint
of Div<BigUint, BigUint> for BigUint
of Rem<BigUint, BigUint> for BigUint
of Neg<BigUint> for BigUint
of Integer for BigUint
of IntConvertible for BigUint
of ToStrRadix for BigUint
of FromStrRadix for BigUint
for BigUint
of ::std::cmp::Eq for Sign
- Automatically derived.of ::std::clone::Clone for Sign
- Automatically derived.of Ord for Sign
of TotalOrd for Sign
of Neg<Sign> for Sign
of ::std::clone::Clone for BigInt
- Automatically derived.of Eq for BigInt
of TotalEq for BigInt
of Ord for BigInt
of TotalOrd for BigInt
of ToStr for BigInt
of FromStr for BigInt
of Num for BigInt
of Orderable for BigInt
of Shl<uint, BigInt> for BigInt
of Shr<uint, BigInt> for BigInt
of Zero for BigInt
of One for BigInt
of Signed for BigInt
of Add<BigInt, BigInt> for BigInt
of Sub<BigInt, BigInt> for BigInt
of Mul<BigInt, BigInt> for BigInt
of Div<BigInt, BigInt> for BigInt
of Rem<BigInt, BigInt> for BigInt
of Neg<BigInt> for BigInt
of Integer for BigInt
of IntConvertible for BigInt
of ToStrRadix for BigInt
of FromStrRadix for BigInt
for BigInt
bigint::BigDigit
BigDigit
type BigDigit = u32
A BigDigit is a BigUint's composing element.
A BigDigit is half the size of machine word size.
Sign
A Sign is a BigInt's composing element.
Minus
Zero
Plus
BigInt
pub struct BigInt {
priv sign: Sign,
priv data: BigUint,
}
A big signed integer type.
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).
::std::clone::Clone
for BigUint
Automatically derived.
clone
fn clone(&self) -> BigUint
Eq
for BigUint
eq
fn eq(&self, other: &BigUint) -> bool
ne
fn ne(&self, other: &BigUint) -> bool
TotalEq
for BigUint
equals
fn equals(&self, other: &BigUint) -> bool
Ord
for BigUint
lt
fn lt(&self, other: &BigUint) -> bool
le
fn le(&self, other: &BigUint) -> bool
ge
fn ge(&self, other: &BigUint) -> bool
gt
fn gt(&self, other: &BigUint) -> bool
TotalOrd
for BigUint
cmp
fn cmp(&self, other: &BigUint) -> Ordering
ToStr
for BigUint
to_str
fn to_str(&self) -> ~str
FromStr
for BigUint
from_str
fn from_str(s: &str) -> Option<BigUint>
Num
for BigUint
Orderable
for BigUint
min
fn min(&self, other: &BigUint) -> BigUint
max
fn max(&self, other: &BigUint) -> BigUint
clamp
fn clamp(&self, mn: &BigUint, mx: &BigUint) -> BigUint
Shl<uint, BigUint>
for BigUint
shl
fn shl(&self, rhs: &uint) -> BigUint
Shr<uint, BigUint>
for BigUint
shr
fn shr(&self, rhs: &uint) -> BigUint
Zero
for BigUint
zero
fn zero() -> BigUint
is_zero
fn is_zero(&self) -> bool
One
for BigUint
one
fn one() -> BigUint
Unsigned
for BigUint
Add<BigUint, BigUint>
for BigUint
add
fn add(&self, other: &BigUint) -> BigUint
Sub<BigUint, BigUint>
for BigUint
sub
fn sub(&self, other: &BigUint) -> BigUint
Mul<BigUint, BigUint>
for BigUint
mul
fn mul(&self, other: &BigUint) -> BigUint
Div<BigUint, BigUint>
for BigUint
div
fn div(&self, other: &BigUint) -> BigUint
Rem<BigUint, BigUint>
for BigUint
rem
fn rem(&self, other: &BigUint) -> BigUint
Neg<BigUint>
for BigUint
neg
fn neg(&self) -> BigUint
Integer
for BigUint
div_rem
fn div_rem(&self, other: &BigUint) -> (BigUint, BigUint)
div_floor
fn div_floor(&self, other: &BigUint) -> BigUint
mod_floor
fn mod_floor(&self, other: &BigUint) -> BigUint
div_mod_floor
fn div_mod_floor(&self, other: &BigUint) -> (BigUint, BigUint)
gcd
fn gcd(&self, other: &BigUint) -> BigUint
Calculates the Greatest Common Divisor (GCD) of the number and other
The result is always positive
lcm
fn lcm(&self, other: &BigUint) -> BigUint
Calculates the Lowest Common Multiple (LCM) of the number and other
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
is_even
fn is_even(&self) -> bool
Returns true
if the number is divisible by 2
is_odd
fn is_odd(&self) -> bool
Returns true
if the number is not divisible by 2
IntConvertible
for BigUint
to_int
fn to_int(&self) -> int
from_int
fn from_int(n: int) -> BigUint
ToStrRadix
for BigUint
to_str_radix
fn to_str_radix(&self, radix: uint) -> ~str
FromStrRadix
for BigUint
from_str_radix
fn from_str_radix(s: &str, radix: uint) -> Option<BigUint>
Creates and initializes an BigUint.
BigUint
new
fn new(v: ~[BigDigit]) -> BigUint
Creates and initializes an BigUint.
from_uint
fn from_uint(n: uint) -> BigUint
Creates and initializes an BigUint.
from_slice
fn from_slice(slice: &[BigDigit]) -> BigUint
Creates and initializes an BigUint.
parse_bytes
fn parse_bytes(buf: &[u8], radix: uint) -> Option<BigUint>
Creates and initializes an BigUint.
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.
::std::cmp::Eq
for Sign
Automatically derived.
eq
fn eq(&self, __arg_0: &Sign) -> ::bool
ne
fn ne(&self, __arg_0: &Sign) -> ::bool
::std::clone::Clone
for Sign
Automatically derived.
clone
fn clone(&self) -> Sign
Ord
for Sign
lt
fn lt(&self, other: &Sign) -> bool
le
fn le(&self, other: &Sign) -> bool
ge
fn ge(&self, other: &Sign) -> bool
gt
fn gt(&self, other: &Sign) -> bool
TotalOrd
for Sign
cmp
fn cmp(&self, other: &Sign) -> Ordering
Neg<Sign>
for Sign
neg
fn neg(&self) -> Sign
Negate Sign value.
::std::clone::Clone
for BigInt
Automatically derived.
clone
fn clone(&self) -> BigInt
Eq
for BigInt
eq
fn eq(&self, other: &BigInt) -> bool
ne
fn ne(&self, other: &BigInt) -> bool
TotalEq
for BigInt
equals
fn equals(&self, other: &BigInt) -> bool
Ord
for BigInt
lt
fn lt(&self, other: &BigInt) -> bool
le
fn le(&self, other: &BigInt) -> bool
ge
fn ge(&self, other: &BigInt) -> bool
gt
fn gt(&self, other: &BigInt) -> bool
TotalOrd
for BigInt
cmp
fn cmp(&self, other: &BigInt) -> Ordering
ToStr
for BigInt
to_str
fn to_str(&self) -> ~str
FromStr
for BigInt
from_str
fn from_str(s: &str) -> Option<BigInt>
Num
for BigInt
Orderable
for BigInt
min
fn min(&self, other: &BigInt) -> BigInt
max
fn max(&self, other: &BigInt) -> BigInt
clamp
fn clamp(&self, mn: &BigInt, mx: &BigInt) -> BigInt
Shl<uint, BigInt>
for BigInt
shl
fn shl(&self, rhs: &uint) -> BigInt
Shr<uint, BigInt>
for BigInt
shr
fn shr(&self, rhs: &uint) -> BigInt
Zero
for BigInt
zero
fn zero() -> BigInt
is_zero
fn is_zero(&self) -> bool
One
for BigInt
one
fn one() -> BigInt
Signed
for BigInt
abs
fn abs(&self) -> BigInt
abs_sub
fn abs_sub(&self, other: &BigInt) -> BigInt
signum
fn signum(&self) -> BigInt
is_positive
fn is_positive(&self) -> bool
is_negative
fn is_negative(&self) -> bool
Add<BigInt, BigInt>
for BigInt
add
fn add(&self, other: &BigInt) -> BigInt
Sub<BigInt, BigInt>
for BigInt
sub
fn sub(&self, other: &BigInt) -> BigInt
Mul<BigInt, BigInt>
for BigInt
mul
fn mul(&self, other: &BigInt) -> BigInt
Div<BigInt, BigInt>
for BigInt
div
fn div(&self, other: &BigInt) -> BigInt
Rem<BigInt, BigInt>
for BigInt
rem
fn rem(&self, other: &BigInt) -> BigInt
Neg<BigInt>
for BigInt
neg
fn neg(&self) -> BigInt
Integer
for BigInt
div_rem
fn div_rem(&self, other: &BigInt) -> (BigInt, BigInt)
div_floor
fn div_floor(&self, other: &BigInt) -> BigInt
mod_floor
fn mod_floor(&self, other: &BigInt) -> BigInt
div_mod_floor
fn div_mod_floor(&self, other: &BigInt) -> (BigInt, BigInt)
gcd
fn gcd(&self, other: &BigInt) -> BigInt
Calculates the Greatest Common Divisor (GCD) of the number and other
The result is always positive
lcm
fn lcm(&self, other: &BigInt) -> BigInt
Calculates the Lowest Common Multiple (LCM) of the number and other
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
is_even
fn is_even(&self) -> bool
Returns true
if the number is divisible by 2
is_odd
fn is_odd(&self) -> bool
Returns true
if the number is not divisible by 2
IntConvertible
for BigInt
to_int
fn to_int(&self) -> int
from_int
fn from_int(n: int) -> BigInt
ToStrRadix
for BigInt
to_str_radix
fn to_str_radix(&self, radix: uint) -> ~str
FromStrRadix
for BigInt
from_str_radix
fn from_str_radix(s: &str, radix: uint) -> Option<BigInt>
Creates and initializes an BigInt.
BigInt
new
fn new(sign: Sign, v: ~[BigDigit]) -> BigInt
Creates and initializes an BigInt.
from_biguint
fn from_biguint(sign: Sign, data: BigUint) -> BigInt
Creates and initializes an BigInt.
from_uint
fn from_uint(n: uint) -> BigInt
Creates and initializes an BigInt.
from_slice
fn from_slice(sign: Sign, slice: &[BigDigit]) -> BigInt
Creates and initializes an BigInt.
parse_bytes
fn parse_bytes(buf: &[u8], radix: uint) -> Option<BigInt>
Creates and initializes an BigInt.
to_uint
fn to_uint(&self) -> uint