Skip to content

Commit 3edc7c0

Browse files
committed
Removed generic infinity, NaN and negative zero functions
Removed Round impl for integers
1 parent df36a8d commit 3edc7c0

File tree

3 files changed

+7
-87
lines changed

3 files changed

+7
-87
lines changed

src/libcore/num/int-template.rs

-12
Original file line numberDiff line numberDiff line change
@@ -177,18 +177,6 @@ impl num::One for T {
177177
static pure fn one() -> T { 1 }
178178
}
179179
180-
impl num::Round for T {
181-
#[inline(always)]
182-
pure fn round(&self, _: num::RoundMode) -> T { *self }
183-
184-
#[inline(always)]
185-
pure fn floor(&self) -> T { *self }
186-
#[inline(always)]
187-
pure fn ceil(&self) -> T { *self }
188-
#[inline(always)]
189-
pure fn fract(&self) -> T { 0 }
190-
}
191-
192180
#[cfg(notest)]
193181
impl ops::Add<T,T> for T {
194182
pure fn add(&self, other: &T) -> T { *self + *other }

src/libcore/num/num.rs

+7-63
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ pub trait Round {
4444
pure fn fract(&self) -> Self;
4545
}
4646

47+
pub enum RoundMode {
48+
RoundDown,
49+
RoundUp,
50+
RoundToZero,
51+
RoundFromZero
52+
}
53+
4754
/**
4855
* Cast a number the the enclosing type
4956
*
@@ -82,13 +89,6 @@ pub trait NumCast {
8289
pure fn to_float(&self) -> float;
8390
}
8491

85-
pub enum RoundMode {
86-
RoundDown,
87-
RoundUp,
88-
RoundToZero,
89-
RoundFromZero
90-
}
91-
9292
pub trait ToStrRadix {
9393
pub pure fn to_str_radix(&self, radix: uint) -> ~str;
9494
}
@@ -99,62 +99,6 @@ pub trait FromStrRadix {
9999

100100
// Generic math functions:
101101

102-
/// Dynamically calculates the value `inf` (`1/0`).
103-
/// Can fail on integer types.
104-
#[inline(always)]
105-
pub pure fn infinity<T:One+Zero+Div<T,T>>() -> T {
106-
let _0: T = Zero::zero();
107-
let _1: T = One::one();
108-
_1 / _0
109-
}
110-
111-
/// Dynamically calculates the value `-inf` (`-1/0`).
112-
/// Can fail on integer types.
113-
#[inline(always)]
114-
pub pure fn neg_infinity<T:One+Zero+Div<T,T>+Neg<T>>() -> T {
115-
let _0: T = Zero::zero();
116-
let _1: T = One::one();
117-
- _1 / _0
118-
}
119-
120-
/// Dynamically calculates the value `NaN` (`0/0`).
121-
/// Can fail on integer types.
122-
#[inline(always)]
123-
pub pure fn NaN<T:Zero+Div<T,T>>() -> T {
124-
let _0: T = Zero::zero();
125-
_0 / _0
126-
}
127-
128-
/// Returns `true` if `num` has the value `inf` (`1/0`).
129-
/// Can fail on integer types.
130-
#[inline(always)]
131-
pub pure fn is_infinity<T:One+Zero+Eq+Div<T,T>>(num: &T) -> bool {
132-
(*num) == (infinity::<T>())
133-
}
134-
135-
/// Returns `true` if `num` has the value `-inf` (`-1/0`).
136-
/// Can fail on integer types.
137-
#[inline(always)]
138-
pub pure fn is_neg_infinity<T:One+Zero+Eq+Div<T,T>+Neg<T>>(num: &T)
139-
-> bool {
140-
(*num) == (neg_infinity::<T>())
141-
}
142-
143-
/// Returns `true` if `num` has the value `NaN` (is not equal to itself).
144-
#[inline(always)]
145-
pub pure fn is_NaN<T:Eq>(num: &T) -> bool {
146-
(*num) != (*num)
147-
}
148-
149-
/// Returns `true` if `num` has the value `-0` (`1/num == -1/0`).
150-
/// Can fail on integer types.
151-
#[inline(always)]
152-
pub pure fn is_neg_zero<T:One+Zero+Eq+Div<T,T>+Neg<T>>(num: &T) -> bool {
153-
let _1: T = One::one();
154-
let _0: T = Zero::zero();
155-
*num == _0 && is_neg_infinity(&(_1 / *num))
156-
}
157-
158102
/**
159103
* Calculates a power to a given radix, optimized for uint `pow` and `radix`.
160104
*

src/libcore/num/uint-template.rs

-12
Original file line numberDiff line numberDiff line change
@@ -141,18 +141,6 @@ impl num::One for T {
141141
static pure fn one() -> T { 1 }
142142
}
143143
144-
impl num::Round for T {
145-
#[inline(always)]
146-
pure fn round(&self, _: num::RoundMode) -> T { *self }
147-
148-
#[inline(always)]
149-
pure fn floor(&self) -> T { *self }
150-
#[inline(always)]
151-
pure fn ceil(&self) -> T { *self }
152-
#[inline(always)]
153-
pure fn fract(&self) -> T { 0 }
154-
}
155-
156144
#[cfg(notest)]
157145
impl ops::Add<T,T> for T {
158146
pure fn add(&self, other: &T) -> T { *self + *other }

0 commit comments

Comments
 (0)