about summary refs log tree commit diff
path: root/src/libextra/num
diff options
context:
space:
mode:
authorJens Nockert <jens@nockert.se>2013-07-08 18:05:17 +0200
committerJens Nockert <jens@nockert.se>2013-07-08 18:05:17 +0200
commit1aae28a57d42bfd56e0838ddee0a44605922d655 (patch)
tree24378e71ef2022a5f6a3021b765b8feba89aa253 /src/libextra/num
parent44770ae3a8001de38b33e449889c6444808941fc (diff)
Replaces the free-standing functions in f32, &c.
The free-standing functions in f32, f64, i8, i16, i32, i64, u8, u16,
u32, u64, float, int, and uint are replaced with generic functions in
num instead.

If you were previously using any of those functions, just replace them
with the corresponding function with the same name in num.

Note: If you were using a function that corresponds to an operator, use
the operator instead.
Diffstat (limited to 'src/libextra/num')
-rw-r--r--src/libextra/num/bigint.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/libextra/num/bigint.rs b/src/libextra/num/bigint.rs
index a0b95924e09..aeffe0d591d 100644
--- a/src/libextra/num/bigint.rs
+++ b/src/libextra/num/bigint.rs
@@ -21,6 +21,7 @@ A BigInt is a combination of BigUint and Sign.
 
 use std::cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater};
 use std::int;
+use std::num;
 use std::num::{IntConvertible, Zero, One, ToStrRadix, FromStrRadix, Orderable};
 use std::str;
 use std::uint;
@@ -204,7 +205,7 @@ impl Unsigned for BigUint {}
 impl Add<BigUint, BigUint> for BigUint {
 
     fn add(&self, other: &BigUint) -> BigUint {
-        let new_len = uint::max(self.data.len(), other.data.len());
+        let new_len = num::max(self.data.len(), other.data.len());
 
         let mut carry = 0;
         let mut sum = do vec::from_fn(new_len) |i| {
@@ -224,7 +225,7 @@ impl Add<BigUint, BigUint> for BigUint {
 impl Sub<BigUint, BigUint> for BigUint {
 
     fn sub(&self, other: &BigUint) -> BigUint {
-        let new_len = uint::max(self.data.len(), other.data.len());
+        let new_len = num::max(self.data.len(), other.data.len());
 
         let mut borrow = 0;
         let diff = do vec::from_fn(new_len) |i| {
@@ -260,7 +261,7 @@ impl Mul<BigUint, BigUint> for BigUint {
         // = a1*b1 * base^2 +
         //   (a1*b1 + a0*b0 - (a1-b0)*(b1-a0)) * base +
         //   a0*b0
-        let half_len = uint::max(s_len, o_len) / 2;
+        let half_len = num::max(s_len, o_len) / 2;
         let (sHi, sLo) = cut_at(self,  half_len);
         let (oHi, oLo) = cut_at(other, half_len);
 
@@ -297,7 +298,7 @@ impl Mul<BigUint, BigUint> for BigUint {
 
 
         fn cut_at(a: &BigUint, n: uint) -> (BigUint, BigUint) {
-            let mid = uint::min(a.data.len(), n);
+            let mid = num::min(a.data.len(), n);
             return (BigUint::from_slice(a.data.slice(mid, a.data.len())),
                     BigUint::from_slice(a.data.slice(0, mid)));
         }
@@ -482,7 +483,7 @@ impl Integer for BigUint {
 impl IntConvertible for BigUint {
 
     fn to_int(&self) -> int {
-        uint::min(self.to_uint(), int::max_value as uint) as int
+        num::min(self.to_uint(), int::max_value as uint) as int
     }
 
 
@@ -580,7 +581,7 @@ impl BigUint {
         let mut n: BigUint      = Zero::zero();
         let mut power: BigUint  = One::one();
         loop {
-            let start = uint::max(end, unit_len) - unit_len;
+            let start = num::max(end, unit_len) - unit_len;
             match uint::parse_bytes(buf.slice(start, end), radix) {
                 // FIXME(#6102): Assignment operator for BigInt causes ICE
                 // Some(d) => n += BigUint::from_uint(d) * power,
@@ -1055,9 +1056,9 @@ impl IntConvertible for BigInt {
 
     fn to_int(&self) -> int {
         match self.sign {
-            Plus  => uint::min(self.to_uint(), int::max_value as uint) as int,
+            Plus  => num::min(self.to_uint(), int::max_value as uint) as int,
             Zero  => 0,
-            Minus => uint::min((-self).to_uint(),
+            Minus => num::min((-self).to_uint(),
                                (int::max_value as uint) + 1) as int
         }
     }