diff options
| author | Marvin Löbel <loebel.marvin@gmail.com> | 2013-02-15 05:46:07 +0100 |
|---|---|---|
| committer | Marvin Löbel <loebel.marvin@gmail.com> | 2013-02-15 05:46:07 +0100 |
| commit | 3edc7c0b9cbdf1b396c81fe1700f0816b9f239d0 (patch) | |
| tree | d8180ad50ae9bd3a4bd260614b155bc68c0b8042 | |
| parent | df36a8dfc98af7e78b416ca1faab3c214be29fab (diff) | |
| download | rust-3edc7c0b9cbdf1b396c81fe1700f0816b9f239d0.tar.gz rust-3edc7c0b9cbdf1b396c81fe1700f0816b9f239d0.zip | |
Removed generic infinity, NaN and negative zero functions
Removed Round impl for integers
| -rw-r--r-- | src/libcore/num/int-template.rs | 12 | ||||
| -rw-r--r-- | src/libcore/num/num.rs | 70 | ||||
| -rw-r--r-- | src/libcore/num/uint-template.rs | 12 |
3 files changed, 7 insertions, 87 deletions
diff --git a/src/libcore/num/int-template.rs b/src/libcore/num/int-template.rs index c0624608a15..8d72878ef6a 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<T,T> 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 af322e9b6c6..e720c2fa108 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:One+Zero+Div<T,T>>() -> 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<T:One+Zero+Div<T,T>+Neg<T>>() -> 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:Zero+Div<T,T>>() -> 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<T:One+Zero+Eq+Div<T,T>>(num: &T) -> bool { - (*num) == (infinity::<T>()) -} - -/// Returns `true` if `num` has the value `-inf` (`-1/0`). -/// Can fail on integer types. -#[inline(always)] -pub pure fn is_neg_infinity<T:One+Zero+Eq+Div<T,T>+Neg<T>>(num: &T) - -> bool { - (*num) == (neg_infinity::<T>()) -} - -/// Returns `true` if `num` has the value `NaN` (is not equal to itself). -#[inline(always)] -pub pure fn is_NaN<T:Eq>(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<T:One+Zero+Eq+Div<T,T>+Neg<T>>(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 c5743b40a89..005f0f2b5a4 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<T,T> for T { pure fn add(&self, other: &T) -> T { *self + *other } |
