Struct extra::bigint::BigInt

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

A big signed integer type.

Methods

impl BigInt

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

Creates and initializes an BigInt.

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

Creates and initializes an BigInt.

fn from_uint(n: uint) -> BigInt

Creates and initializes an BigInt.

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

Creates and initializes an BigInt.

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

Creates and initializes an BigInt.

fn to_uint(&self) -> uint

Converts this BigInt into a uint, failing if the conversion would overflow.

fn to_uint_opt(&self) -> std::option::Option

Converts this BigInt into a uint, unless it would overflow.

fn to_int_opt(&self) -> std::option::Option

Converts this BigInt into an int, unless it would overflow.

fn to_biguint(&self) -> BigUint

Converts this BigInt into a BigUint, failing if BigInt is negative.

fn to_biguint_opt(&self) -> std::option::Option

Converts this BigInt into a BigUint, if it's not negative.

Trait Implementations

impl std::clone::Clone for BigInt

fn clone(&self) -> BigInt

impl std::cmp::Eq for BigInt

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

impl std::cmp::TotalEq for BigInt

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

impl std::cmp::Ord for BigInt

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

impl std::cmp::TotalOrd for BigInt

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

impl std::to_str::ToStr for BigInt

fn to_str(&self) -> ~str

impl std::from_str::FromStr for BigInt

fn from_str(s: &str) -> std::option::Option

impl std::num::Num for BigInt

impl std::num::Orderable for BigInt

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

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

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

impl std::ops::Shl for BigInt

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

impl std::ops::Shr for BigInt

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

impl std::num::Zero for BigInt

fn zero() -> BigInt

fn is_zero(&self) -> bool

impl std::num::One for BigInt

fn one() -> BigInt

impl std::num::Signed for BigInt

fn abs(&self) -> BigInt

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

fn signum(&self) -> BigInt

fn is_positive(&self) -> bool

fn is_negative(&self) -> bool

impl std::ops::Add for BigInt

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

impl std::ops::Sub for BigInt

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

impl std::ops::Mul for BigInt

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

impl std::ops::Div for BigInt

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

impl std::ops::Rem for BigInt

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

impl std::ops::Neg for BigInt

fn neg(&self) -> BigInt

impl std::num::Integer for BigInt

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

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

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

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

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

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

The result is always positive

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

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

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

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

fn is_even(&self) -> bool

Returns true if the number is divisible by 2

fn is_odd(&self) -> bool

Returns true if the number is not divisible by 2

impl std::num::IntConvertible for BigInt

fn to_int(&self) -> int

fn from_int(n: int) -> BigInt

impl std::num::ToStrRadix for BigInt

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

impl std::num::FromStrRadix for BigInt

fn from_str_radix(s: &str, radix: uint) -> std::option::Option

Creates and initializes an BigInt.