diff --git a/src/libcore/num/int-template.rs b/src/libcore/num/int-template.rs index c0624608a15f5..8d72878ef6acb 100644 --- a/src/libcore/num/int-template.rs +++ b/src/libcore/num/int-template.rs @@ -177,18 +177,6 @@ impl num::One for T { static pure fn one() -> T { 1 } } -impl num::Round for T { - #[inline(always)] - pure fn round(&self, _: num::RoundMode) -> T { *self } - - #[inline(always)] - pure fn floor(&self) -> T { *self } - #[inline(always)] - pure fn ceil(&self) -> T { *self } - #[inline(always)] - pure fn fract(&self) -> T { 0 } -} - #[cfg(notest)] impl ops::Add for T { pure fn add(&self, other: &T) -> T { *self + *other } diff --git a/src/libcore/num/num.rs b/src/libcore/num/num.rs index af322e9b6c6fd..e720c2fa108ae 100644 --- a/src/libcore/num/num.rs +++ b/src/libcore/num/num.rs @@ -44,6 +44,13 @@ pub trait Round { pure fn fract(&self) -> Self; } +pub enum RoundMode { + RoundDown, + RoundUp, + RoundToZero, + RoundFromZero +} + /** * Cast a number the the enclosing type * @@ -82,13 +89,6 @@ pub trait NumCast { pure fn to_float(&self) -> float; } -pub enum RoundMode { - RoundDown, - RoundUp, - RoundToZero, - RoundFromZero -} - pub trait ToStrRadix { pub pure fn to_str_radix(&self, radix: uint) -> ~str; } @@ -99,62 +99,6 @@ pub trait FromStrRadix { // Generic math functions: -/// Dynamically calculates the value `inf` (`1/0`). -/// Can fail on integer types. -#[inline(always)] -pub pure fn infinity>() -> T { - let _0: T = Zero::zero(); - let _1: T = One::one(); - _1 / _0 -} - -/// Dynamically calculates the value `-inf` (`-1/0`). -/// Can fail on integer types. -#[inline(always)] -pub pure fn neg_infinity+Neg>() -> T { - let _0: T = Zero::zero(); - let _1: T = One::one(); - - _1 / _0 -} - -/// Dynamically calculates the value `NaN` (`0/0`). -/// Can fail on integer types. -#[inline(always)] -pub pure fn NaN>() -> T { - let _0: T = Zero::zero(); - _0 / _0 -} - -/// Returns `true` if `num` has the value `inf` (`1/0`). -/// Can fail on integer types. -#[inline(always)] -pub pure fn is_infinity>(num: &T) -> bool { - (*num) == (infinity::()) -} - -/// Returns `true` if `num` has the value `-inf` (`-1/0`). -/// Can fail on integer types. -#[inline(always)] -pub pure fn is_neg_infinity+Neg>(num: &T) - -> bool { - (*num) == (neg_infinity::()) -} - -/// Returns `true` if `num` has the value `NaN` (is not equal to itself). -#[inline(always)] -pub pure fn is_NaN(num: &T) -> bool { - (*num) != (*num) -} - -/// Returns `true` if `num` has the value `-0` (`1/num == -1/0`). -/// Can fail on integer types. -#[inline(always)] -pub pure fn is_neg_zero+Neg>(num: &T) -> bool { - let _1: T = One::one(); - let _0: T = Zero::zero(); - *num == _0 && is_neg_infinity(&(_1 / *num)) -} - /** * Calculates a power to a given radix, optimized for uint `pow` and `radix`. * diff --git a/src/libcore/num/uint-template.rs b/src/libcore/num/uint-template.rs index c5743b40a89e4..005f0f2b5a4df 100644 --- a/src/libcore/num/uint-template.rs +++ b/src/libcore/num/uint-template.rs @@ -141,18 +141,6 @@ impl num::One for T { static pure fn one() -> T { 1 } } -impl num::Round for T { - #[inline(always)] - pure fn round(&self, _: num::RoundMode) -> T { *self } - - #[inline(always)] - pure fn floor(&self) -> T { *self } - #[inline(always)] - pure fn ceil(&self) -> T { *self } - #[inline(always)] - pure fn fract(&self) -> T { 0 } -} - #[cfg(notest)] impl ops::Add for T { pure fn add(&self, other: &T) -> T { *self + *other }