bigint: inlining small functions
This commit is contained in:
parent
b247d17629
commit
17c8f8bd0c
1 changed files with 92 additions and 97 deletions
|
@ -58,19 +58,19 @@ pub mod BigDigit {
|
||||||
static hi_mask: uint = (-1 as uint) << bits;
|
static hi_mask: uint = (-1 as uint) << bits;
|
||||||
static lo_mask: uint = (-1 as uint) >> bits;
|
static lo_mask: uint = (-1 as uint) >> bits;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn get_hi(n: uint) -> BigDigit { (n >> bits) as BigDigit }
|
fn get_hi(n: uint) -> BigDigit { (n >> bits) as BigDigit }
|
||||||
|
#[inline]
|
||||||
fn get_lo(n: uint) -> BigDigit { (n & lo_mask) as BigDigit }
|
fn get_lo(n: uint) -> BigDigit { (n & lo_mask) as BigDigit }
|
||||||
|
|
||||||
/// Split one machine sized unsigned integer into two BigDigits.
|
/// Split one machine sized unsigned integer into two BigDigits.
|
||||||
|
#[inline]
|
||||||
pub fn from_uint(n: uint) -> (BigDigit, BigDigit) {
|
pub fn from_uint(n: uint) -> (BigDigit, BigDigit) {
|
||||||
(get_hi(n), get_lo(n))
|
(get_hi(n), get_lo(n))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Join two BigDigits into one machine sized unsigned integer
|
/// Join two BigDigits into one machine sized unsigned integer
|
||||||
|
#[inline]
|
||||||
pub fn to_uint(hi: BigDigit, lo: BigDigit) -> uint {
|
pub fn to_uint(hi: BigDigit, lo: BigDigit) -> uint {
|
||||||
(lo as uint) | ((hi as uint) << bits)
|
(lo as uint) | ((hi as uint) << bits)
|
||||||
}
|
}
|
||||||
|
@ -88,24 +88,26 @@ pub struct BigUint {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Eq for BigUint {
|
impl Eq for BigUint {
|
||||||
|
#[inline]
|
||||||
fn eq(&self, other: &BigUint) -> bool { self.equals(other) }
|
fn eq(&self, other: &BigUint) -> bool { self.equals(other) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TotalEq for BigUint {
|
impl TotalEq for BigUint {
|
||||||
|
#[inline]
|
||||||
fn equals(&self, other: &BigUint) -> bool {
|
fn equals(&self, other: &BigUint) -> bool {
|
||||||
match self.cmp(other) { Equal => true, _ => false }
|
match self.cmp(other) { Equal => true, _ => false }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Ord for BigUint {
|
impl Ord for BigUint {
|
||||||
|
#[inline]
|
||||||
fn lt(&self, other: &BigUint) -> bool {
|
fn lt(&self, other: &BigUint) -> bool {
|
||||||
match self.cmp(other) { Less => true, _ => false}
|
match self.cmp(other) { Less => true, _ => false}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TotalOrd for BigUint {
|
impl TotalOrd for BigUint {
|
||||||
|
#[inline]
|
||||||
fn cmp(&self, other: &BigUint) -> Ordering {
|
fn cmp(&self, other: &BigUint) -> Ordering {
|
||||||
let (s_len, o_len) = (self.data.len(), other.data.len());
|
let (s_len, o_len) = (self.data.len(), other.data.len());
|
||||||
if s_len < o_len { return Less; }
|
if s_len < o_len { return Less; }
|
||||||
|
@ -120,12 +122,12 @@ impl TotalOrd for BigUint {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToStr for BigUint {
|
impl ToStr for BigUint {
|
||||||
|
#[inline]
|
||||||
fn to_str(&self) -> ~str { self.to_str_radix(10) }
|
fn to_str(&self) -> ~str { self.to_str_radix(10) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromStr for BigUint {
|
impl FromStr for BigUint {
|
||||||
|
#[inline]
|
||||||
fn from_str(s: &str) -> Option<BigUint> {
|
fn from_str(s: &str) -> Option<BigUint> {
|
||||||
FromStrRadix::from_str_radix(s, 10)
|
FromStrRadix::from_str_radix(s, 10)
|
||||||
}
|
}
|
||||||
|
@ -134,17 +136,17 @@ impl FromStr for BigUint {
|
||||||
impl Num for BigUint {}
|
impl Num for BigUint {}
|
||||||
|
|
||||||
impl Orderable for BigUint {
|
impl Orderable for BigUint {
|
||||||
|
#[inline]
|
||||||
fn min(&self, other: &BigUint) -> BigUint {
|
fn min(&self, other: &BigUint) -> BigUint {
|
||||||
if self < other { self.clone() } else { other.clone() }
|
if self < other { self.clone() } else { other.clone() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn max(&self, other: &BigUint) -> BigUint {
|
fn max(&self, other: &BigUint) -> BigUint {
|
||||||
if self > other { self.clone() } else { other.clone() }
|
if self > other { self.clone() } else { other.clone() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn clamp(&self, mn: &BigUint, mx: &BigUint) -> BigUint {
|
fn clamp(&self, mn: &BigUint, mx: &BigUint) -> BigUint {
|
||||||
if self > mx { mx.clone() } else
|
if self > mx { mx.clone() } else
|
||||||
if self < mn { mn.clone() } else { self.clone() }
|
if self < mn { mn.clone() } else { self.clone() }
|
||||||
|
@ -152,7 +154,7 @@ impl Orderable for BigUint {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Shl<uint, BigUint> for BigUint {
|
impl Shl<uint, BigUint> for BigUint {
|
||||||
|
#[inline]
|
||||||
fn shl(&self, rhs: &uint) -> BigUint {
|
fn shl(&self, rhs: &uint) -> BigUint {
|
||||||
let n_unit = *rhs / BigDigit::bits;
|
let n_unit = *rhs / BigDigit::bits;
|
||||||
let n_bits = *rhs % BigDigit::bits;
|
let n_bits = *rhs % BigDigit::bits;
|
||||||
|
@ -161,7 +163,7 @@ impl Shl<uint, BigUint> for BigUint {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Shr<uint, BigUint> for BigUint {
|
impl Shr<uint, BigUint> for BigUint {
|
||||||
|
#[inline]
|
||||||
fn shr(&self, rhs: &uint) -> BigUint {
|
fn shr(&self, rhs: &uint) -> BigUint {
|
||||||
let n_unit = *rhs / BigDigit::bits;
|
let n_unit = *rhs / BigDigit::bits;
|
||||||
let n_bits = *rhs % BigDigit::bits;
|
let n_bits = *rhs % BigDigit::bits;
|
||||||
|
@ -170,22 +172,21 @@ impl Shr<uint, BigUint> for BigUint {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Zero for BigUint {
|
impl Zero for BigUint {
|
||||||
|
#[inline]
|
||||||
fn zero() -> BigUint { BigUint::new(~[]) }
|
fn zero() -> BigUint { BigUint::new(~[]) }
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn is_zero(&self) -> bool { self.data.is_empty() }
|
fn is_zero(&self) -> bool { self.data.is_empty() }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl One for BigUint {
|
impl One for BigUint {
|
||||||
|
#[inline]
|
||||||
fn one() -> BigUint { BigUint::new(~[1]) }
|
fn one() -> BigUint { BigUint::new(~[1]) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Unsigned for BigUint {}
|
impl Unsigned for BigUint {}
|
||||||
|
|
||||||
impl Add<BigUint, BigUint> for BigUint {
|
impl Add<BigUint, BigUint> for BigUint {
|
||||||
|
|
||||||
fn add(&self, other: &BigUint) -> BigUint {
|
fn add(&self, other: &BigUint) -> BigUint {
|
||||||
let new_len = num::max(self.data.len(), other.data.len());
|
let new_len = num::max(self.data.len(), other.data.len());
|
||||||
|
|
||||||
|
@ -205,7 +206,6 @@ impl Add<BigUint, BigUint> for BigUint {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Sub<BigUint, BigUint> for BigUint {
|
impl Sub<BigUint, BigUint> for BigUint {
|
||||||
|
|
||||||
fn sub(&self, other: &BigUint) -> BigUint {
|
fn sub(&self, other: &BigUint) -> BigUint {
|
||||||
let new_len = num::max(self.data.len(), other.data.len());
|
let new_len = num::max(self.data.len(), other.data.len());
|
||||||
|
|
||||||
|
@ -278,14 +278,14 @@ impl Mul<BigUint, BigUint> for BigUint {
|
||||||
return BigUint::new(prod);
|
return BigUint::new(prod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn cut_at(a: &BigUint, n: uint) -> (BigUint, BigUint) {
|
fn cut_at(a: &BigUint, n: uint) -> (BigUint, BigUint) {
|
||||||
let mid = num::min(a.data.len(), n);
|
let mid = num::min(a.data.len(), n);
|
||||||
return (BigUint::from_slice(a.data.slice(mid, a.data.len())),
|
return (BigUint::from_slice(a.data.slice(mid, a.data.len())),
|
||||||
BigUint::from_slice(a.data.slice(0, mid)));
|
BigUint::from_slice(a.data.slice(0, mid)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn sub_sign(a: BigUint, b: BigUint) -> (Ordering, BigUint) {
|
fn sub_sign(a: BigUint, b: BigUint) -> (Ordering, BigUint) {
|
||||||
match a.cmp(&b) {
|
match a.cmp(&b) {
|
||||||
Less => (Less, b - a),
|
Less => (Less, b - a),
|
||||||
|
@ -297,7 +297,7 @@ impl Mul<BigUint, BigUint> for BigUint {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Div<BigUint, BigUint> for BigUint {
|
impl Div<BigUint, BigUint> for BigUint {
|
||||||
|
#[inline]
|
||||||
fn div(&self, other: &BigUint) -> BigUint {
|
fn div(&self, other: &BigUint) -> BigUint {
|
||||||
let (q, _) = self.div_rem(other);
|
let (q, _) = self.div_rem(other);
|
||||||
return q;
|
return q;
|
||||||
|
@ -305,7 +305,7 @@ impl Div<BigUint, BigUint> for BigUint {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Rem<BigUint, BigUint> for BigUint {
|
impl Rem<BigUint, BigUint> for BigUint {
|
||||||
|
#[inline]
|
||||||
fn rem(&self, other: &BigUint) -> BigUint {
|
fn rem(&self, other: &BigUint) -> BigUint {
|
||||||
let (_, r) = self.div_rem(other);
|
let (_, r) = self.div_rem(other);
|
||||||
return r;
|
return r;
|
||||||
|
@ -313,29 +313,28 @@ impl Rem<BigUint, BigUint> for BigUint {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Neg<BigUint> for BigUint {
|
impl Neg<BigUint> for BigUint {
|
||||||
|
#[inline]
|
||||||
fn neg(&self) -> BigUint { fail!() }
|
fn neg(&self) -> BigUint { fail!() }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Integer for BigUint {
|
impl Integer for BigUint {
|
||||||
|
#[inline]
|
||||||
fn div_rem(&self, other: &BigUint) -> (BigUint, BigUint) {
|
fn div_rem(&self, other: &BigUint) -> (BigUint, BigUint) {
|
||||||
self.div_mod_floor(other)
|
self.div_mod_floor(other)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn div_floor(&self, other: &BigUint) -> BigUint {
|
fn div_floor(&self, other: &BigUint) -> BigUint {
|
||||||
let (d, _) = self.div_mod_floor(other);
|
let (d, _) = self.div_mod_floor(other);
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn mod_floor(&self, other: &BigUint) -> BigUint {
|
fn mod_floor(&self, other: &BigUint) -> BigUint {
|
||||||
let (_, m) = self.div_mod_floor(other);
|
let (_, m) = self.div_mod_floor(other);
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn div_mod_floor(&self, other: &BigUint) -> (BigUint, BigUint) {
|
fn div_mod_floor(&self, other: &BigUint) -> (BigUint, BigUint) {
|
||||||
if other.is_zero() { fail!() }
|
if other.is_zero() { fail!() }
|
||||||
if self.is_zero() { return (Zero::zero(), Zero::zero()); }
|
if self.is_zero() { return (Zero::zero(), Zero::zero()); }
|
||||||
|
@ -423,7 +422,7 @@ impl Integer for BigUint {
|
||||||
*
|
*
|
||||||
* The result is always positive
|
* The result is always positive
|
||||||
*/
|
*/
|
||||||
|
#[inline]
|
||||||
fn gcd(&self, other: &BigUint) -> BigUint {
|
fn gcd(&self, other: &BigUint) -> BigUint {
|
||||||
// Use Euclid's algorithm
|
// Use Euclid's algorithm
|
||||||
let mut m = (*self).clone();
|
let mut m = (*self).clone();
|
||||||
|
@ -439,15 +438,15 @@ impl Integer for BigUint {
|
||||||
/**
|
/**
|
||||||
* Calculates the Lowest Common Multiple (LCM) of the number and `other`
|
* Calculates the Lowest Common Multiple (LCM) of the number and `other`
|
||||||
*/
|
*/
|
||||||
|
#[inline]
|
||||||
fn lcm(&self, other: &BigUint) -> BigUint { ((*self * *other) / self.gcd(other)) }
|
fn lcm(&self, other: &BigUint) -> BigUint { ((*self * *other) / self.gcd(other)) }
|
||||||
|
|
||||||
/// Returns `true` if the number can be divided by `other` without leaving a remainder
|
/// Returns `true` if the number can be divided by `other` without leaving a remainder
|
||||||
|
#[inline]
|
||||||
fn is_multiple_of(&self, other: &BigUint) -> bool { (*self % *other).is_zero() }
|
fn is_multiple_of(&self, other: &BigUint) -> bool { (*self % *other).is_zero() }
|
||||||
|
|
||||||
/// Returns `true` if the number is divisible by `2`
|
/// Returns `true` if the number is divisible by `2`
|
||||||
|
#[inline]
|
||||||
fn is_even(&self) -> bool {
|
fn is_even(&self) -> bool {
|
||||||
// Considering only the last digit.
|
// Considering only the last digit.
|
||||||
if self.data.is_empty() {
|
if self.data.is_empty() {
|
||||||
|
@ -458,24 +457,23 @@ impl Integer for BigUint {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if the number is not divisible by `2`
|
/// Returns `true` if the number is not divisible by `2`
|
||||||
|
#[inline]
|
||||||
fn is_odd(&self) -> bool { !self.is_even() }
|
fn is_odd(&self) -> bool { !self.is_even() }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntConvertible for BigUint {
|
impl IntConvertible for BigUint {
|
||||||
|
#[inline]
|
||||||
fn to_int(&self) -> int {
|
fn to_int(&self) -> int {
|
||||||
num::min(self.to_uint(), int::max_value as uint) as int
|
num::min(self.to_uint(), int::max_value as uint) as int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn from_int(n: int) -> BigUint {
|
fn from_int(n: int) -> BigUint {
|
||||||
if (n < 0) { Zero::zero() } else { BigUint::from_uint(n as uint) }
|
if (n < 0) { Zero::zero() } else { BigUint::from_uint(n as uint) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToStrRadix for BigUint {
|
impl ToStrRadix for BigUint {
|
||||||
|
|
||||||
fn to_str_radix(&self, radix: uint) -> ~str {
|
fn to_str_radix(&self, radix: uint) -> ~str {
|
||||||
assert!(1 < radix && radix <= 16);
|
assert!(1 < radix && radix <= 16);
|
||||||
let (base, max_len) = get_radix_base(radix);
|
let (base, max_len) = get_radix_base(radix);
|
||||||
|
@ -484,7 +482,6 @@ impl ToStrRadix for BigUint {
|
||||||
}
|
}
|
||||||
return fill_concat(convert_base((*self).clone(), base), radix, max_len);
|
return fill_concat(convert_base((*self).clone(), base), radix, max_len);
|
||||||
|
|
||||||
|
|
||||||
fn convert_base(n: BigUint, base: uint) -> ~[BigDigit] {
|
fn convert_base(n: BigUint, base: uint) -> ~[BigDigit] {
|
||||||
let divider = BigUint::from_uint(base);
|
let divider = BigUint::from_uint(base);
|
||||||
let mut result = ~[];
|
let mut result = ~[];
|
||||||
|
@ -500,7 +497,6 @@ impl ToStrRadix for BigUint {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn fill_concat(v: &[BigDigit], radix: uint, l: uint) -> ~str {
|
fn fill_concat(v: &[BigDigit], radix: uint, l: uint) -> ~str {
|
||||||
if v.is_empty() { return ~"0" }
|
if v.is_empty() { return ~"0" }
|
||||||
let mut s = str::with_capacity(v.len() * l);
|
let mut s = str::with_capacity(v.len() * l);
|
||||||
|
@ -516,7 +512,7 @@ impl ToStrRadix for BigUint {
|
||||||
|
|
||||||
impl FromStrRadix for BigUint {
|
impl FromStrRadix for BigUint {
|
||||||
/// Creates and initializes an BigUint.
|
/// Creates and initializes an BigUint.
|
||||||
|
#[inline]
|
||||||
fn from_str_radix(s: &str, radix: uint)
|
fn from_str_radix(s: &str, radix: uint)
|
||||||
-> Option<BigUint> {
|
-> Option<BigUint> {
|
||||||
BigUint::parse_bytes(s.as_bytes(), radix)
|
BigUint::parse_bytes(s.as_bytes(), radix)
|
||||||
|
@ -525,7 +521,7 @@ impl FromStrRadix for BigUint {
|
||||||
|
|
||||||
impl BigUint {
|
impl BigUint {
|
||||||
/// Creates and initializes an BigUint.
|
/// Creates and initializes an BigUint.
|
||||||
|
#[inline]
|
||||||
pub fn new(v: ~[BigDigit]) -> BigUint {
|
pub fn new(v: ~[BigDigit]) -> BigUint {
|
||||||
// omit trailing zeros
|
// omit trailing zeros
|
||||||
let new_len = v.rposition(|n| *n != 0).map_move_default(0, |p| p + 1);
|
let new_len = v.rposition(|n| *n != 0).map_move_default(0, |p| p + 1);
|
||||||
|
@ -537,7 +533,7 @@ impl BigUint {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates and initializes an BigUint.
|
/// Creates and initializes an BigUint.
|
||||||
|
#[inline]
|
||||||
pub fn from_uint(n: uint) -> BigUint {
|
pub fn from_uint(n: uint) -> BigUint {
|
||||||
match BigDigit::from_uint(n) {
|
match BigDigit::from_uint(n) {
|
||||||
(0, 0) => Zero::zero(),
|
(0, 0) => Zero::zero(),
|
||||||
|
@ -547,13 +543,12 @@ impl BigUint {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates and initializes an BigUint.
|
/// Creates and initializes an BigUint.
|
||||||
|
#[inline]
|
||||||
pub fn from_slice(slice: &[BigDigit]) -> BigUint {
|
pub fn from_slice(slice: &[BigDigit]) -> BigUint {
|
||||||
return BigUint::new(slice.to_owned());
|
return BigUint::new(slice.to_owned());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates and initializes an BigUint.
|
/// Creates and initializes an BigUint.
|
||||||
|
|
||||||
pub fn parse_bytes(buf: &[u8], radix: uint)
|
pub fn parse_bytes(buf: &[u8], radix: uint)
|
||||||
-> Option<BigUint> {
|
-> Option<BigUint> {
|
||||||
let (base, unit_len) = get_radix_base(radix);
|
let (base, unit_len) = get_radix_base(radix);
|
||||||
|
@ -583,6 +578,7 @@ impl BigUint {
|
||||||
|
|
||||||
/// Converts this big integer into a uint, returning the uint::max_value if
|
/// Converts this big integer into a uint, returning the uint::max_value if
|
||||||
/// it's too large to fit in a uint.
|
/// it's too large to fit in a uint.
|
||||||
|
#[inline]
|
||||||
pub fn to_uint(&self) -> uint {
|
pub fn to_uint(&self) -> uint {
|
||||||
match self.data.len() {
|
match self.data.len() {
|
||||||
0 => 0,
|
0 => 0,
|
||||||
|
@ -592,7 +588,7 @@ impl BigUint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn shl_unit(&self, n_unit: uint) -> BigUint {
|
fn shl_unit(&self, n_unit: uint) -> BigUint {
|
||||||
if n_unit == 0 || self.is_zero() { return (*self).clone(); }
|
if n_unit == 0 || self.is_zero() { return (*self).clone(); }
|
||||||
|
|
||||||
|
@ -600,7 +596,7 @@ impl BigUint {
|
||||||
+ self.data);
|
+ self.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn shl_bits(&self, n_bits: uint) -> BigUint {
|
fn shl_bits(&self, n_bits: uint) -> BigUint {
|
||||||
if n_bits == 0 || self.is_zero() { return (*self).clone(); }
|
if n_bits == 0 || self.is_zero() { return (*self).clone(); }
|
||||||
|
|
||||||
|
@ -616,7 +612,7 @@ impl BigUint {
|
||||||
return BigUint::new(shifted);
|
return BigUint::new(shifted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn shr_unit(&self, n_unit: uint) -> BigUint {
|
fn shr_unit(&self, n_unit: uint) -> BigUint {
|
||||||
if n_unit == 0 { return (*self).clone(); }
|
if n_unit == 0 { return (*self).clone(); }
|
||||||
if self.data.len() < n_unit { return Zero::zero(); }
|
if self.data.len() < n_unit { return Zero::zero(); }
|
||||||
|
@ -625,7 +621,7 @@ impl BigUint {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn shr_bits(&self, n_bits: uint) -> BigUint {
|
fn shr_bits(&self, n_bits: uint) -> BigUint {
|
||||||
if n_bits == 0 || self.data.is_empty() { return (*self).clone(); }
|
if n_bits == 0 || self.data.is_empty() { return (*self).clone(); }
|
||||||
|
|
||||||
|
@ -640,6 +636,7 @@ impl BigUint {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_word_size = "64")]
|
#[cfg(target_word_size = "64")]
|
||||||
|
#[inline]
|
||||||
fn get_radix_base(radix: uint) -> (uint, uint) {
|
fn get_radix_base(radix: uint) -> (uint, uint) {
|
||||||
assert!(1 < radix && radix <= 16);
|
assert!(1 < radix && radix <= 16);
|
||||||
match radix {
|
match radix {
|
||||||
|
@ -663,6 +660,7 @@ fn get_radix_base(radix: uint) -> (uint, uint) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_word_size = "32")]
|
#[cfg(target_word_size = "32")]
|
||||||
|
#[inline]
|
||||||
fn get_radix_base(radix: uint) -> (uint, uint) {
|
fn get_radix_base(radix: uint) -> (uint, uint) {
|
||||||
assert!(1 < radix && radix <= 16);
|
assert!(1 < radix && radix <= 16);
|
||||||
match radix {
|
match radix {
|
||||||
|
@ -690,19 +688,18 @@ fn get_radix_base(radix: uint) -> (uint, uint) {
|
||||||
pub enum Sign { Minus, Zero, Plus }
|
pub enum Sign { Minus, Zero, Plus }
|
||||||
|
|
||||||
impl Ord for Sign {
|
impl Ord for Sign {
|
||||||
|
#[inline]
|
||||||
fn lt(&self, other: &Sign) -> bool {
|
fn lt(&self, other: &Sign) -> bool {
|
||||||
match self.cmp(other) { Less => true, _ => false}
|
match self.cmp(other) { Less => true, _ => false}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TotalEq for Sign {
|
impl TotalEq for Sign {
|
||||||
fn equals(&self, other: &Sign) -> bool {
|
#[inline]
|
||||||
*self == *other
|
fn equals(&self, other: &Sign) -> bool { *self == *other }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
impl TotalOrd for Sign {
|
impl TotalOrd for Sign {
|
||||||
|
#[inline]
|
||||||
fn cmp(&self, other: &Sign) -> Ordering {
|
fn cmp(&self, other: &Sign) -> Ordering {
|
||||||
match (*self, *other) {
|
match (*self, *other) {
|
||||||
(Minus, Minus) | (Zero, Zero) | (Plus, Plus) => Equal,
|
(Minus, Minus) | (Zero, Zero) | (Plus, Plus) => Equal,
|
||||||
|
@ -714,7 +711,7 @@ impl TotalOrd for Sign {
|
||||||
|
|
||||||
impl Neg<Sign> for Sign {
|
impl Neg<Sign> for Sign {
|
||||||
/// Negate Sign value.
|
/// Negate Sign value.
|
||||||
|
#[inline]
|
||||||
fn neg(&self) -> Sign {
|
fn neg(&self) -> Sign {
|
||||||
match *self {
|
match *self {
|
||||||
Minus => Plus,
|
Minus => Plus,
|
||||||
|
@ -732,26 +729,26 @@ pub struct BigInt {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Eq for BigInt {
|
impl Eq for BigInt {
|
||||||
|
#[inline]
|
||||||
fn eq(&self, other: &BigInt) -> bool { self.equals(other) }
|
fn eq(&self, other: &BigInt) -> bool { self.equals(other) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TotalEq for BigInt {
|
impl TotalEq for BigInt {
|
||||||
|
#[inline]
|
||||||
fn equals(&self, other: &BigInt) -> bool {
|
fn equals(&self, other: &BigInt) -> bool {
|
||||||
match self.cmp(other) { Equal => true, _ => false }
|
match self.cmp(other) { Equal => true, _ => false }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Ord for BigInt {
|
impl Ord for BigInt {
|
||||||
|
#[inline]
|
||||||
fn lt(&self, other: &BigInt) -> bool {
|
fn lt(&self, other: &BigInt) -> bool {
|
||||||
match self.cmp(other) { Less => true, _ => false}
|
match self.cmp(other) { Less => true, _ => false}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TotalOrd for BigInt {
|
impl TotalOrd for BigInt {
|
||||||
|
#[inline]
|
||||||
fn cmp(&self, other: &BigInt) -> Ordering {
|
fn cmp(&self, other: &BigInt) -> Ordering {
|
||||||
let scmp = self.sign.cmp(&other.sign);
|
let scmp = self.sign.cmp(&other.sign);
|
||||||
if scmp != Equal { return scmp; }
|
if scmp != Equal { return scmp; }
|
||||||
|
@ -765,12 +762,12 @@ impl TotalOrd for BigInt {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToStr for BigInt {
|
impl ToStr for BigInt {
|
||||||
|
#[inline]
|
||||||
fn to_str(&self) -> ~str { self.to_str_radix(10) }
|
fn to_str(&self) -> ~str { self.to_str_radix(10) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromStr for BigInt {
|
impl FromStr for BigInt {
|
||||||
|
#[inline]
|
||||||
fn from_str(s: &str) -> Option<BigInt> {
|
fn from_str(s: &str) -> Option<BigInt> {
|
||||||
FromStrRadix::from_str_radix(s, 10)
|
FromStrRadix::from_str_radix(s, 10)
|
||||||
}
|
}
|
||||||
|
@ -779,17 +776,17 @@ impl FromStr for BigInt {
|
||||||
impl Num for BigInt {}
|
impl Num for BigInt {}
|
||||||
|
|
||||||
impl Orderable for BigInt {
|
impl Orderable for BigInt {
|
||||||
|
#[inline]
|
||||||
fn min(&self, other: &BigInt) -> BigInt {
|
fn min(&self, other: &BigInt) -> BigInt {
|
||||||
if self < other { self.clone() } else { other.clone() }
|
if self < other { self.clone() } else { other.clone() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn max(&self, other: &BigInt) -> BigInt {
|
fn max(&self, other: &BigInt) -> BigInt {
|
||||||
if self > other { self.clone() } else { other.clone() }
|
if self > other { self.clone() } else { other.clone() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn clamp(&self, mn: &BigInt, mx: &BigInt) -> BigInt {
|
fn clamp(&self, mn: &BigInt, mx: &BigInt) -> BigInt {
|
||||||
if self > mx { mx.clone() } else
|
if self > mx { mx.clone() } else
|
||||||
if self < mn { mn.clone() } else { self.clone() }
|
if self < mn { mn.clone() } else { self.clone() }
|
||||||
|
@ -797,38 +794,38 @@ impl Orderable for BigInt {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Shl<uint, BigInt> for BigInt {
|
impl Shl<uint, BigInt> for BigInt {
|
||||||
|
#[inline]
|
||||||
fn shl(&self, rhs: &uint) -> BigInt {
|
fn shl(&self, rhs: &uint) -> BigInt {
|
||||||
BigInt::from_biguint(self.sign, self.data << *rhs)
|
BigInt::from_biguint(self.sign, self.data << *rhs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Shr<uint, BigInt> for BigInt {
|
impl Shr<uint, BigInt> for BigInt {
|
||||||
|
#[inline]
|
||||||
fn shr(&self, rhs: &uint) -> BigInt {
|
fn shr(&self, rhs: &uint) -> BigInt {
|
||||||
BigInt::from_biguint(self.sign, self.data >> *rhs)
|
BigInt::from_biguint(self.sign, self.data >> *rhs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Zero for BigInt {
|
impl Zero for BigInt {
|
||||||
|
#[inline]
|
||||||
fn zero() -> BigInt {
|
fn zero() -> BigInt {
|
||||||
BigInt::from_biguint(Zero, Zero::zero())
|
BigInt::from_biguint(Zero, Zero::zero())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn is_zero(&self) -> bool { self.sign == Zero }
|
fn is_zero(&self) -> bool { self.sign == Zero }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl One for BigInt {
|
impl One for BigInt {
|
||||||
|
#[inline]
|
||||||
fn one() -> BigInt {
|
fn one() -> BigInt {
|
||||||
BigInt::from_biguint(Plus, One::one())
|
BigInt::from_biguint(Plus, One::one())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Signed for BigInt {
|
impl Signed for BigInt {
|
||||||
|
#[inline]
|
||||||
fn abs(&self) -> BigInt {
|
fn abs(&self) -> BigInt {
|
||||||
match self.sign {
|
match self.sign {
|
||||||
Plus | Zero => self.clone(),
|
Plus | Zero => self.clone(),
|
||||||
|
@ -836,12 +833,12 @@ impl Signed for BigInt {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn abs_sub(&self, other: &BigInt) -> BigInt {
|
fn abs_sub(&self, other: &BigInt) -> BigInt {
|
||||||
if *self <= *other { Zero::zero() } else { *self - *other }
|
if *self <= *other { Zero::zero() } else { *self - *other }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn signum(&self) -> BigInt {
|
fn signum(&self) -> BigInt {
|
||||||
match self.sign {
|
match self.sign {
|
||||||
Plus => BigInt::from_biguint(Plus, One::one()),
|
Plus => BigInt::from_biguint(Plus, One::one()),
|
||||||
|
@ -850,15 +847,15 @@ impl Signed for BigInt {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn is_positive(&self) -> bool { self.sign == Plus }
|
fn is_positive(&self) -> bool { self.sign == Plus }
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn is_negative(&self) -> bool { self.sign == Minus }
|
fn is_negative(&self) -> bool { self.sign == Minus }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Add<BigInt, BigInt> for BigInt {
|
impl Add<BigInt, BigInt> for BigInt {
|
||||||
|
#[inline]
|
||||||
fn add(&self, other: &BigInt) -> BigInt {
|
fn add(&self, other: &BigInt) -> BigInt {
|
||||||
match (self.sign, other.sign) {
|
match (self.sign, other.sign) {
|
||||||
(Zero, _) => other.clone(),
|
(Zero, _) => other.clone(),
|
||||||
|
@ -873,7 +870,7 @@ impl Add<BigInt, BigInt> for BigInt {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Sub<BigInt, BigInt> for BigInt {
|
impl Sub<BigInt, BigInt> for BigInt {
|
||||||
|
#[inline]
|
||||||
fn sub(&self, other: &BigInt) -> BigInt {
|
fn sub(&self, other: &BigInt) -> BigInt {
|
||||||
match (self.sign, other.sign) {
|
match (self.sign, other.sign) {
|
||||||
(Zero, _) => -other,
|
(Zero, _) => -other,
|
||||||
|
@ -891,7 +888,7 @@ impl Sub<BigInt, BigInt> for BigInt {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Mul<BigInt, BigInt> for BigInt {
|
impl Mul<BigInt, BigInt> for BigInt {
|
||||||
|
#[inline]
|
||||||
fn mul(&self, other: &BigInt) -> BigInt {
|
fn mul(&self, other: &BigInt) -> BigInt {
|
||||||
match (self.sign, other.sign) {
|
match (self.sign, other.sign) {
|
||||||
(Zero, _) | (_, Zero) => Zero::zero(),
|
(Zero, _) | (_, Zero) => Zero::zero(),
|
||||||
|
@ -906,7 +903,7 @@ impl Mul<BigInt, BigInt> for BigInt {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Div<BigInt, BigInt> for BigInt {
|
impl Div<BigInt, BigInt> for BigInt {
|
||||||
|
#[inline]
|
||||||
fn div(&self, other: &BigInt) -> BigInt {
|
fn div(&self, other: &BigInt) -> BigInt {
|
||||||
let (q, _) = self.div_rem(other);
|
let (q, _) = self.div_rem(other);
|
||||||
return q;
|
return q;
|
||||||
|
@ -914,7 +911,7 @@ impl Div<BigInt, BigInt> for BigInt {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Rem<BigInt, BigInt> for BigInt {
|
impl Rem<BigInt, BigInt> for BigInt {
|
||||||
|
#[inline]
|
||||||
fn rem(&self, other: &BigInt) -> BigInt {
|
fn rem(&self, other: &BigInt) -> BigInt {
|
||||||
let (_, r) = self.div_rem(other);
|
let (_, r) = self.div_rem(other);
|
||||||
return r;
|
return r;
|
||||||
|
@ -922,14 +919,14 @@ impl Rem<BigInt, BigInt> for BigInt {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Neg<BigInt> for BigInt {
|
impl Neg<BigInt> for BigInt {
|
||||||
|
#[inline]
|
||||||
fn neg(&self) -> BigInt {
|
fn neg(&self) -> BigInt {
|
||||||
BigInt::from_biguint(self.sign.neg(), self.data.clone())
|
BigInt::from_biguint(self.sign.neg(), self.data.clone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Integer for BigInt {
|
impl Integer for BigInt {
|
||||||
|
#[inline]
|
||||||
fn div_rem(&self, other: &BigInt) -> (BigInt, BigInt) {
|
fn div_rem(&self, other: &BigInt) -> (BigInt, BigInt) {
|
||||||
// r.sign == self.sign
|
// r.sign == self.sign
|
||||||
let (d_ui, r_ui) = self.data.div_mod_floor(&other.data);
|
let (d_ui, r_ui) = self.data.div_mod_floor(&other.data);
|
||||||
|
@ -944,19 +941,18 @@ impl Integer for BigInt {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn div_floor(&self, other: &BigInt) -> BigInt {
|
fn div_floor(&self, other: &BigInt) -> BigInt {
|
||||||
let (d, _) = self.div_mod_floor(other);
|
let (d, _) = self.div_mod_floor(other);
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn mod_floor(&self, other: &BigInt) -> BigInt {
|
fn mod_floor(&self, other: &BigInt) -> BigInt {
|
||||||
let (_, m) = self.div_mod_floor(other);
|
let (_, m) = self.div_mod_floor(other);
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn div_mod_floor(&self, other: &BigInt) -> (BigInt, BigInt) {
|
fn div_mod_floor(&self, other: &BigInt) -> (BigInt, BigInt) {
|
||||||
// m.sign == other.sign
|
// m.sign == other.sign
|
||||||
let (d_ui, m_ui) = self.data.div_rem(&other.data);
|
let (d_ui, m_ui) = self.data.div_rem(&other.data);
|
||||||
|
@ -984,7 +980,7 @@ impl Integer for BigInt {
|
||||||
*
|
*
|
||||||
* The result is always positive
|
* The result is always positive
|
||||||
*/
|
*/
|
||||||
|
#[inline]
|
||||||
fn gcd(&self, other: &BigInt) -> BigInt {
|
fn gcd(&self, other: &BigInt) -> BigInt {
|
||||||
BigInt::from_biguint(Plus, self.data.gcd(&other.data))
|
BigInt::from_biguint(Plus, self.data.gcd(&other.data))
|
||||||
}
|
}
|
||||||
|
@ -992,26 +988,26 @@ impl Integer for BigInt {
|
||||||
/**
|
/**
|
||||||
* Calculates the Lowest Common Multiple (LCM) of the number and `other`
|
* Calculates the Lowest Common Multiple (LCM) of the number and `other`
|
||||||
*/
|
*/
|
||||||
|
#[inline]
|
||||||
fn lcm(&self, other: &BigInt) -> BigInt {
|
fn lcm(&self, other: &BigInt) -> BigInt {
|
||||||
BigInt::from_biguint(Plus, self.data.lcm(&other.data))
|
BigInt::from_biguint(Plus, self.data.lcm(&other.data))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if the number can be divided by `other` without leaving a remainder
|
/// Returns `true` if the number can be divided by `other` without leaving a remainder
|
||||||
|
#[inline]
|
||||||
fn is_multiple_of(&self, other: &BigInt) -> bool { self.data.is_multiple_of(&other.data) }
|
fn is_multiple_of(&self, other: &BigInt) -> bool { self.data.is_multiple_of(&other.data) }
|
||||||
|
|
||||||
/// Returns `true` if the number is divisible by `2`
|
/// Returns `true` if the number is divisible by `2`
|
||||||
|
#[inline]
|
||||||
fn is_even(&self) -> bool { self.data.is_even() }
|
fn is_even(&self) -> bool { self.data.is_even() }
|
||||||
|
|
||||||
/// Returns `true` if the number is not divisible by `2`
|
/// Returns `true` if the number is not divisible by `2`
|
||||||
|
#[inline]
|
||||||
fn is_odd(&self) -> bool { self.data.is_odd() }
|
fn is_odd(&self) -> bool { self.data.is_odd() }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntConvertible for BigInt {
|
impl IntConvertible for BigInt {
|
||||||
|
#[inline]
|
||||||
fn to_int(&self) -> int {
|
fn to_int(&self) -> int {
|
||||||
match self.sign {
|
match self.sign {
|
||||||
Plus => num::min(self.to_uint(), int::max_value as uint) as int,
|
Plus => num::min(self.to_uint(), int::max_value as uint) as int,
|
||||||
|
@ -1021,7 +1017,7 @@ impl IntConvertible for BigInt {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn from_int(n: int) -> BigInt {
|
fn from_int(n: int) -> BigInt {
|
||||||
if n > 0 {
|
if n > 0 {
|
||||||
return BigInt::from_biguint(Plus, BigUint::from_uint(n as uint));
|
return BigInt::from_biguint(Plus, BigUint::from_uint(n as uint));
|
||||||
|
@ -1036,7 +1032,7 @@ impl IntConvertible for BigInt {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToStrRadix for BigInt {
|
impl ToStrRadix for BigInt {
|
||||||
|
#[inline]
|
||||||
fn to_str_radix(&self, radix: uint) -> ~str {
|
fn to_str_radix(&self, radix: uint) -> ~str {
|
||||||
match self.sign {
|
match self.sign {
|
||||||
Plus => self.data.to_str_radix(radix),
|
Plus => self.data.to_str_radix(radix),
|
||||||
|
@ -1048,21 +1044,21 @@ impl ToStrRadix for BigInt {
|
||||||
|
|
||||||
impl FromStrRadix for BigInt {
|
impl FromStrRadix for BigInt {
|
||||||
/// Creates and initializes an BigInt.
|
/// Creates and initializes an BigInt.
|
||||||
|
#[inline]
|
||||||
fn from_str_radix(s: &str, radix: uint)
|
fn from_str_radix(s: &str, radix: uint) -> Option<BigInt> {
|
||||||
-> Option<BigInt> {
|
|
||||||
BigInt::parse_bytes(s.as_bytes(), radix)
|
BigInt::parse_bytes(s.as_bytes(), radix)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BigInt {
|
impl BigInt {
|
||||||
/// Creates and initializes an BigInt.
|
/// Creates and initializes an BigInt.
|
||||||
|
#[inline]
|
||||||
pub fn new(sign: Sign, v: ~[BigDigit]) -> BigInt {
|
pub fn new(sign: Sign, v: ~[BigDigit]) -> BigInt {
|
||||||
BigInt::from_biguint(sign, BigUint::new(v))
|
BigInt::from_biguint(sign, BigUint::new(v))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates and initializes an BigInt.
|
/// Creates and initializes an BigInt.
|
||||||
|
#[inline]
|
||||||
pub fn from_biguint(sign: Sign, data: BigUint) -> BigInt {
|
pub fn from_biguint(sign: Sign, data: BigUint) -> BigInt {
|
||||||
if sign == Zero || data.is_zero() {
|
if sign == Zero || data.is_zero() {
|
||||||
return BigInt { sign: Zero, data: Zero::zero() };
|
return BigInt { sign: Zero, data: Zero::zero() };
|
||||||
|
@ -1071,20 +1067,19 @@ impl BigInt {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates and initializes an BigInt.
|
/// Creates and initializes an BigInt.
|
||||||
|
#[inline]
|
||||||
pub fn from_uint(n: uint) -> BigInt {
|
pub fn from_uint(n: uint) -> BigInt {
|
||||||
if n == 0 { return Zero::zero(); }
|
if n == 0 { return Zero::zero(); }
|
||||||
return BigInt::from_biguint(Plus, BigUint::from_uint(n));
|
return BigInt::from_biguint(Plus, BigUint::from_uint(n));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates and initializes an BigInt.
|
/// Creates and initializes an BigInt.
|
||||||
|
#[inline]
|
||||||
pub fn from_slice(sign: Sign, slice: &[BigDigit]) -> BigInt {
|
pub fn from_slice(sign: Sign, slice: &[BigDigit]) -> BigInt {
|
||||||
BigInt::from_biguint(sign, BigUint::from_slice(slice))
|
BigInt::from_biguint(sign, BigUint::from_slice(slice))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates and initializes an BigInt.
|
/// Creates and initializes an BigInt.
|
||||||
|
|
||||||
pub fn parse_bytes(buf: &[u8], radix: uint)
|
pub fn parse_bytes(buf: &[u8], radix: uint)
|
||||||
-> Option<BigInt> {
|
-> Option<BigInt> {
|
||||||
if buf.is_empty() { return None; }
|
if buf.is_empty() { return None; }
|
||||||
|
@ -1098,6 +1093,7 @@ impl BigInt {
|
||||||
.map_move(|bu| BigInt::from_biguint(sign, bu));
|
.map_move(|bu| BigInt::from_biguint(sign, bu));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
pub fn to_uint(&self) -> uint {
|
pub fn to_uint(&self) -> uint {
|
||||||
match self.sign {
|
match self.sign {
|
||||||
Plus => self.data.to_uint(),
|
Plus => self.data.to_uint(),
|
||||||
|
@ -1577,7 +1573,6 @@ mod biguint_tests {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod bigint_tests {
|
mod bigint_tests {
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
use std::cmp::{Less, Equal, Greater};
|
use std::cmp::{Less, Equal, Greater};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue