diff options
| author | Brendan Zabarauskas <bjzaba@yahoo.com.au> | 2014-01-30 22:39:58 +1100 |
|---|---|---|
| committer | Brendan Zabarauskas <bjzaba@yahoo.com.au> | 2014-02-01 13:03:02 +1100 |
| commit | 1388c053a8b59347b607674fb5b83910d309aa9b (patch) | |
| tree | 32f90c705c36f5eaafd2a8ccfa916ed317449ad4 /src/libstd/num | |
| parent | 4109caffc320018d93e9ae7f739d6f25dfe003f1 (diff) | |
| download | rust-1388c053a8b59347b607674fb5b83910d309aa9b.tar.gz rust-1388c053a8b59347b607674fb5b83910d309aa9b.zip | |
Remove free-standing div functions in std::uint
Diffstat (limited to 'src/libstd/num')
| -rw-r--r-- | src/libstd/num/uint.rs | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/src/libstd/num/uint.rs b/src/libstd/num/uint.rs index 7954cdc92f0..34611d43677 100644 --- a/src/libstd/num/uint.rs +++ b/src/libstd/num/uint.rs @@ -25,59 +25,6 @@ use unstable::intrinsics; uint_module!(uint, int, ::int::BITS) -/// -/// Divide two numbers, return the result, rounded up. -/// -/// # Arguments -/// -/// * x - an integer -/// * y - an integer distinct from 0u -/// -/// # Return value -/// -/// The smallest integer `q` such that `x/y <= q`. -/// -pub fn div_ceil(x: uint, y: uint) -> uint { - let div = x / y; - if x % y == 0u { div } - else { div + 1u } -} - -/// -/// Divide two numbers, return the result, rounded to the closest integer. -/// -/// # Arguments -/// -/// * x - an integer -/// * y - an integer distinct from 0u -/// -/// # Return value -/// -/// The integer `q` closest to `x/y`. -/// -pub fn div_round(x: uint, y: uint) -> uint { - let div = x / y; - if x % y * 2u < y { div } - else { div + 1u } -} - -/// -/// Divide two numbers, return the result, rounded down. -/// -/// Note: This is the same function as `div`. -/// -/// # Arguments -/// -/// * x - an integer -/// * y - an integer distinct from 0u -/// -/// # Return value -/// -/// The smallest integer `q` such that `x/y <= q`. This -/// is either `x/y` or `x/y + 1`. -/// -pub fn div_floor(x: uint, y: uint) -> uint { return x / y; } - #[cfg(target_word_size = "32")] impl CheckedAdd for uint { #[inline] @@ -151,10 +98,3 @@ fn test_overflows() { assert!((uint::MIN <= 0u)); assert!((uint::MIN + uint::MAX + 1u == 0u)); } - -#[test] -fn test_div() { - assert!((div_floor(3u, 4u) == 0u)); - assert!((div_ceil(3u, 4u) == 1u)); - assert!((div_round(3u, 4u) == 1u)); -} |
