diff options
Diffstat (limited to 'src/libcore/num/float.rs')
| -rw-r--r-- | src/libcore/num/float.rs | 120 |
1 files changed, 60 insertions, 60 deletions
diff --git a/src/libcore/num/float.rs b/src/libcore/num/float.rs index f1026ce6608..4e9a1b62b6e 100644 --- a/src/libcore/num/float.rs +++ b/src/libcore/num/float.rs @@ -103,7 +103,7 @@ pub mod consts { * * num - The float value */ #[inline(always)] -pub pure fn to_str(num: float) -> ~str { +pub fn to_str(num: float) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigAll); r @@ -117,7 +117,7 @@ pub pure fn to_str(num: float) -> ~str { * * num - The float value */ #[inline(always)] -pub pure fn to_str_hex(num: float) -> ~str { +pub fn to_str_hex(num: float) -> ~str { let (r, _) = strconv::to_str_common( &num, 16u, true, strconv::SignNeg, strconv::DigAll); r @@ -138,7 +138,7 @@ pub pure fn to_str_hex(num: float) -> ~str { * are expected, use `to_str_radix_special()` instead. */ #[inline(always)] -pub pure fn to_str_radix(num: float, radix: uint) -> ~str { +pub fn to_str_radix(num: float, radix: uint) -> ~str { let (r, special) = strconv::to_str_common( &num, radix, true, strconv::SignNeg, strconv::DigAll); if special { fail!(~"number has a special value, \ @@ -156,7 +156,7 @@ pub pure fn to_str_radix(num: float, radix: uint) -> ~str { * * radix - The base to use */ #[inline(always)] -pub pure fn to_str_radix_special(num: float, radix: uint) -> (~str, bool) { +pub fn to_str_radix_special(num: float, radix: uint) -> (~str, bool) { strconv::to_str_common(&num, radix, true, strconv::SignNeg, strconv::DigAll) } @@ -171,7 +171,7 @@ pub pure fn to_str_radix_special(num: float, radix: uint) -> (~str, bool) { * * digits - The number of significant digits */ #[inline(always)] -pub pure fn to_str_exact(num: float, digits: uint) -> ~str { +pub fn to_str_exact(num: float, digits: uint) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigExact(digits)); r @@ -193,7 +193,7 @@ pub fn test_to_str_exact_do_decimal() { * * digits - The number of significant digits */ #[inline(always)] -pub pure fn to_str_digits(num: float, digits: uint) -> ~str { +pub fn to_str_digits(num: float, digits: uint) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigMax(digits)); r @@ -201,12 +201,12 @@ pub pure fn to_str_digits(num: float, digits: uint) -> ~str { impl to_str::ToStr for float { #[inline(always)] - pure fn to_str(&self) -> ~str { to_str_digits(*self, 8) } + fn to_str(&self) -> ~str { to_str_digits(*self, 8) } } impl num::ToStrRadix for float { #[inline(always)] - pure fn to_str_radix(&self, radix: uint) -> ~str { + fn to_str_radix(&self, radix: uint) -> ~str { to_str_radix(*self, radix) } } @@ -239,7 +239,7 @@ impl num::ToStrRadix for float { * `Some(n)` where `n` is the floating-point number represented by `num`. */ #[inline(always)] -pub pure fn from_str(num: &str) -> Option<float> { +pub fn from_str(num: &str) -> Option<float> { strconv::from_str_common(num, 10u, true, true, true, strconv::ExpDec, false) } @@ -272,7 +272,7 @@ pub pure fn from_str(num: &str) -> Option<float> { * `Some(n)` where `n` is the floating-point number represented by `[num]`. */ #[inline(always)] -pub pure fn from_str_hex(num: &str) -> Option<float> { +pub fn from_str_hex(num: &str) -> Option<float> { strconv::from_str_common(num, 16u, true, true, true, strconv::ExpBin, false) } @@ -297,19 +297,19 @@ pub pure fn from_str_hex(num: &str) -> Option<float> { * `Some(n)` where `n` is the floating-point number represented by `num`. */ #[inline(always)] -pub pure fn from_str_radix(num: &str, radix: uint) -> Option<float> { +pub fn from_str_radix(num: &str, radix: uint) -> Option<float> { strconv::from_str_common(num, radix, true, true, false, strconv::ExpNone, false) } impl from_str::FromStr for float { #[inline(always)] - pure fn from_str(val: &str) -> Option<float> { from_str(val) } + fn from_str(val: &str) -> Option<float> { from_str(val) } } impl num::FromStrRadix for float { #[inline(always)] - pure fn from_str_radix(val: &str, radix: uint) -> Option<float> { + fn from_str_radix(val: &str, radix: uint) -> Option<float> { from_str_radix(val, radix) } } @@ -330,7 +330,7 @@ impl num::FromStrRadix for float { * * `NaN` if both `x` and `pow` are `0u`, otherwise `x^pow` */ -pub pure fn pow_with_uint(base: uint, pow: uint) -> float { +pub fn pow_with_uint(base: uint, pow: uint) -> float { if base == 0u { if pow == 0u { return NaN as float; @@ -351,69 +351,69 @@ pub pure fn pow_with_uint(base: uint, pow: uint) -> float { } #[inline(always)] -pub pure fn is_positive(x: float) -> bool { f64::is_positive(x as f64) } +pub fn is_positive(x: float) -> bool { f64::is_positive(x as f64) } #[inline(always)] -pub pure fn is_negative(x: float) -> bool { f64::is_negative(x as f64) } +pub fn is_negative(x: float) -> bool { f64::is_negative(x as f64) } #[inline(always)] -pub pure fn is_nonpositive(x: float) -> bool { f64::is_nonpositive(x as f64) } +pub fn is_nonpositive(x: float) -> bool { f64::is_nonpositive(x as f64) } #[inline(always)] -pub pure fn is_nonnegative(x: float) -> bool { f64::is_nonnegative(x as f64) } +pub fn is_nonnegative(x: float) -> bool { f64::is_nonnegative(x as f64) } #[inline(always)] -pub pure fn is_zero(x: float) -> bool { f64::is_zero(x as f64) } +pub fn is_zero(x: float) -> bool { f64::is_zero(x as f64) } #[inline(always)] -pub pure fn is_infinite(x: float) -> bool { f64::is_infinite(x as f64) } +pub fn is_infinite(x: float) -> bool { f64::is_infinite(x as f64) } #[inline(always)] -pub pure fn is_finite(x: float) -> bool { f64::is_finite(x as f64) } +pub fn is_finite(x: float) -> bool { f64::is_finite(x as f64) } #[inline(always)] -pub pure fn is_NaN(x: float) -> bool { f64::is_NaN(x as f64) } +pub fn is_NaN(x: float) -> bool { f64::is_NaN(x as f64) } #[inline(always)] -pub pure fn abs(x: float) -> float { +pub fn abs(x: float) -> float { unsafe { f64::abs(x as f64) as float } } #[inline(always)] -pub pure fn sqrt(x: float) -> float { +pub fn sqrt(x: float) -> float { unsafe { f64::sqrt(x as f64) as float } } #[inline(always)] -pub pure fn atan(x: float) -> float { +pub fn atan(x: float) -> float { unsafe { f64::atan(x as f64) as float } } #[inline(always)] -pub pure fn sin(x: float) -> float { +pub fn sin(x: float) -> float { unsafe { f64::sin(x as f64) as float } } #[inline(always)] -pub pure fn cos(x: float) -> float { +pub fn cos(x: float) -> float { unsafe { f64::cos(x as f64) as float } } #[inline(always)] -pub pure fn tan(x: float) -> float { +pub fn tan(x: float) -> float { unsafe { f64::tan(x as f64) as float } } #[cfg(notest)] impl Eq for float { - pure fn eq(&self, other: &float) -> bool { (*self) == (*other) } - pure fn ne(&self, other: &float) -> bool { (*self) != (*other) } + fn eq(&self, other: &float) -> bool { (*self) == (*other) } + fn ne(&self, other: &float) -> bool { (*self) != (*other) } } #[cfg(notest)] impl Ord for float { - pure fn lt(&self, other: &float) -> bool { (*self) < (*other) } - pure fn le(&self, other: &float) -> bool { (*self) <= (*other) } - pure fn ge(&self, other: &float) -> bool { (*self) >= (*other) } - pure fn gt(&self, other: &float) -> bool { (*self) > (*other) } + fn lt(&self, other: &float) -> bool { (*self) < (*other) } + fn le(&self, other: &float) -> bool { (*self) <= (*other) } + fn ge(&self, other: &float) -> bool { (*self) >= (*other) } + fn gt(&self, other: &float) -> bool { (*self) > (*other) } } impl num::Zero for float { #[inline(always)] - pure fn zero() -> float { 0.0 } + fn zero() -> float { 0.0 } } impl num::One for float { #[inline(always)] - pure fn one() -> float { 1.0 } + fn one() -> float { 1.0 } } impl NumCast for float { @@ -421,28 +421,28 @@ impl NumCast for float { * Cast `n` to a `float` */ #[inline(always)] - pure fn from<N:NumCast>(n: N) -> float { n.to_float() } + fn from<N:NumCast>(n: N) -> float { n.to_float() } - #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } - #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } - #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } - #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } - #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + #[inline(always)] fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] fn to_uint(&self) -> uint { *self as uint } - #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } - #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } - #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } - #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } - #[inline(always)] pure fn to_int(&self) -> int { *self as int } + #[inline(always)] fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] fn to_int(&self) -> int { *self as int } - #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } - #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } - #[inline(always)] pure fn to_float(&self) -> float { *self } + #[inline(always)] fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] fn to_float(&self) -> float { *self } } impl num::Round for float { #[inline(always)] - pure fn round(&self, mode: num::RoundMode) -> float { + fn round(&self, mode: num::RoundMode) -> float { match mode { num::RoundDown => f64::floor(*self as f64) as float, @@ -460,11 +460,11 @@ impl num::Round for float { } #[inline(always)] - pure fn floor(&self) -> float { f64::floor(*self as f64) as float} + fn floor(&self) -> float { f64::floor(*self as f64) as float} #[inline(always)] - pure fn ceil(&self) -> float { f64::ceil(*self as f64) as float} + fn ceil(&self) -> float { f64::ceil(*self as f64) as float} #[inline(always)] - pure fn fract(&self) -> float { + fn fract(&self) -> float { if is_negative(*self) { (*self) - (f64::ceil(*self as f64) as float) } else { @@ -475,27 +475,27 @@ impl num::Round for float { #[cfg(notest)] impl ops::Add<float,float> for float { - pure fn add(&self, other: &float) -> float { *self + *other } + fn add(&self, other: &float) -> float { *self + *other } } #[cfg(notest)] impl ops::Sub<float,float> for float { - pure fn sub(&self, other: &float) -> float { *self - *other } + fn sub(&self, other: &float) -> float { *self - *other } } #[cfg(notest)] impl ops::Mul<float,float> for float { - pure fn mul(&self, other: &float) -> float { *self * *other } + fn mul(&self, other: &float) -> float { *self * *other } } #[cfg(notest)] impl ops::Div<float,float> for float { - pure fn div(&self, other: &float) -> float { *self / *other } + fn div(&self, other: &float) -> float { *self / *other } } #[cfg(notest)] impl ops::Modulo<float,float> for float { - pure fn modulo(&self, other: &float) -> float { *self % *other } + fn modulo(&self, other: &float) -> float { *self % *other } } #[cfg(notest)] impl ops::Neg<float> for float { - pure fn neg(&self) -> float { -*self } + fn neg(&self) -> float { -*self } } #[test] |
