diff options
| author | Graydon Hoare <graydon@mozilla.com> | 2013-06-18 14:45:18 -0700 |
|---|---|---|
| committer | Graydon Hoare <graydon@mozilla.com> | 2013-06-18 14:48:48 -0700 |
| commit | d904c72af830bd4bec773ce35897703dff2ee3b1 (patch) | |
| tree | c9253d1282f12af3aac7e854cd1115cd2eede863 /src/libstd/num/float.rs | |
| parent | 303d7bfc87ca370354ac4264cc23a80cbcd8a792 (diff) | |
| download | rust-d904c72af830bd4bec773ce35897703dff2ee3b1.tar.gz rust-d904c72af830bd4bec773ce35897703dff2ee3b1.zip | |
replace #[inline(always)] with #[inline]. r=burningtree.
Diffstat (limited to 'src/libstd/num/float.rs')
| -rw-r--r-- | src/libstd/num/float.rs | 258 |
1 files changed, 129 insertions, 129 deletions
diff --git a/src/libstd/num/float.rs b/src/libstd/num/float.rs index 267a8890e82..c583aeacf16 100644 --- a/src/libstd/num/float.rs +++ b/src/libstd/num/float.rs @@ -99,7 +99,7 @@ pub mod consts { /// /// * num - The float value /// -#[inline(always)] +#[inline] pub fn to_str(num: float) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigAll); @@ -113,7 +113,7 @@ pub fn to_str(num: float) -> ~str { /// /// * num - The float value /// -#[inline(always)] +#[inline] pub fn to_str_hex(num: float) -> ~str { let (r, _) = strconv::to_str_common( &num, 16u, true, strconv::SignNeg, strconv::DigAll); @@ -134,7 +134,7 @@ pub fn to_str_hex(num: float) -> ~str { /// possible misinterpretation of the result at higher bases. If those values /// are expected, use `to_str_radix_special()` instead. /// -#[inline(always)] +#[inline] pub fn to_str_radix(num: float, radix: uint) -> ~str { let (r, special) = strconv::to_str_common( &num, radix, true, strconv::SignNeg, strconv::DigAll); @@ -152,7 +152,7 @@ pub fn to_str_radix(num: float, radix: uint) -> ~str { /// * num - The float value /// * radix - The base to use /// -#[inline(always)] +#[inline] pub fn to_str_radix_special(num: float, radix: uint) -> (~str, bool) { strconv::to_str_common(&num, radix, true, strconv::SignNeg, strconv::DigAll) @@ -167,7 +167,7 @@ pub fn to_str_radix_special(num: float, radix: uint) -> (~str, bool) { /// * num - The float value /// * digits - The number of significant digits /// -#[inline(always)] +#[inline] pub fn to_str_exact(num: float, digits: uint) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigExact(digits)); @@ -183,7 +183,7 @@ pub fn to_str_exact(num: float, digits: uint) -> ~str { /// * num - The float value /// * digits - The number of significant digits /// -#[inline(always)] +#[inline] pub fn to_str_digits(num: float, digits: uint) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigMax(digits)); @@ -191,12 +191,12 @@ pub fn to_str_digits(num: float, digits: uint) -> ~str { } impl to_str::ToStr for float { - #[inline(always)] + #[inline] fn to_str(&self) -> ~str { to_str_digits(*self, 8) } } impl num::ToStrRadix for float { - #[inline(always)] + #[inline] fn to_str_radix(&self, radix: uint) -> ~str { to_str_radix(*self, radix) } @@ -229,7 +229,7 @@ impl num::ToStrRadix for float { /// `none` if the string did not represent a valid number. Otherwise, /// `Some(n)` where `n` is the floating-point number represented by `num`. /// -#[inline(always)] +#[inline] pub fn from_str(num: &str) -> Option<float> { strconv::from_str_common(num, 10u, true, true, true, strconv::ExpDec, false, false) @@ -262,7 +262,7 @@ pub fn from_str(num: &str) -> Option<float> { /// `none` if the string did not represent a valid number. Otherwise, /// `Some(n)` where `n` is the floating-point number represented by `[num]`. /// -#[inline(always)] +#[inline] pub fn from_str_hex(num: &str) -> Option<float> { strconv::from_str_common(num, 16u, true, true, true, strconv::ExpBin, false, false) @@ -287,19 +287,19 @@ pub fn from_str_hex(num: &str) -> Option<float> { /// `none` if the string did not represent a valid number. Otherwise, /// `Some(n)` where `n` is the floating-point number represented by `num`. /// -#[inline(always)] +#[inline] pub fn from_str_radix(num: &str, radix: uint) -> Option<float> { strconv::from_str_common(num, radix, true, true, false, strconv::ExpNone, false, false) } impl FromStr for float { - #[inline(always)] + #[inline] fn from_str(val: &str) -> Option<float> { from_str(val) } } impl num::FromStrRadix for float { - #[inline(always)] + #[inline] fn from_str_radix(val: &str, radix: uint) -> Option<float> { from_str_radix(val, radix) } @@ -341,27 +341,27 @@ pub fn pow_with_uint(base: uint, pow: uint) -> float { return total; } -#[inline(always)] +#[inline] pub fn abs(x: float) -> float { f64::abs(x as f64) as float } -#[inline(always)] +#[inline] pub fn sqrt(x: float) -> float { f64::sqrt(x as f64) as float } -#[inline(always)] +#[inline] pub fn atan(x: float) -> float { f64::atan(x as f64) as float } -#[inline(always)] +#[inline] pub fn sin(x: float) -> float { f64::sin(x as f64) as float } -#[inline(always)] +#[inline] pub fn cos(x: float) -> float { f64::cos(x as f64) as float } -#[inline(always)] +#[inline] pub fn tan(x: float) -> float { f64::tan(x as f64) as float } @@ -370,23 +370,23 @@ impl Num for float {} #[cfg(not(test))] impl Eq for float { - #[inline(always)] + #[inline] fn eq(&self, other: &float) -> bool { (*self) == (*other) } - #[inline(always)] + #[inline] fn ne(&self, other: &float) -> bool { (*self) != (*other) } } #[cfg(not(test))] impl ApproxEq<float> for float { - #[inline(always)] + #[inline] fn approx_epsilon() -> float { 1.0e-6 } - #[inline(always)] + #[inline] fn approx_eq(&self, other: &float) -> bool { self.approx_eq_eps(other, &ApproxEq::approx_epsilon::<float, float>()) } - #[inline(always)] + #[inline] fn approx_eq_eps(&self, other: &float, approx_epsilon: &float) -> bool { (*self - *other).abs() < *approx_epsilon } @@ -394,66 +394,66 @@ impl ApproxEq<float> for float { #[cfg(not(test))] impl Ord for float { - #[inline(always)] + #[inline] fn lt(&self, other: &float) -> bool { (*self) < (*other) } - #[inline(always)] + #[inline] fn le(&self, other: &float) -> bool { (*self) <= (*other) } - #[inline(always)] + #[inline] fn ge(&self, other: &float) -> bool { (*self) >= (*other) } - #[inline(always)] + #[inline] fn gt(&self, other: &float) -> bool { (*self) > (*other) } } impl Orderable for float { /// Returns `NaN` if either of the numbers are `NaN`. - #[inline(always)] + #[inline] fn min(&self, other: &float) -> float { (*self as f64).min(&(*other as f64)) as float } /// Returns `NaN` if either of the numbers are `NaN`. - #[inline(always)] + #[inline] fn max(&self, other: &float) -> float { (*self as f64).max(&(*other as f64)) as float } /// Returns the number constrained within the range `mn <= self <= mx`. /// If any of the numbers are `NaN` then `NaN` is returned. - #[inline(always)] + #[inline] fn clamp(&self, mn: &float, mx: &float) -> float { (*self as f64).clamp(&(*mn as f64), &(*mx as f64)) as float } } impl Zero for float { - #[inline(always)] + #[inline] fn zero() -> float { 0.0 } /// Returns true if the number is equal to either `0.0` or `-0.0` - #[inline(always)] + #[inline] fn is_zero(&self) -> bool { *self == 0.0 || *self == -0.0 } } impl One for float { - #[inline(always)] + #[inline] fn one() -> float { 1.0 } } impl Round for float { /// Round half-way cases toward `neg_infinity` - #[inline(always)] + #[inline] fn floor(&self) -> float { floor(*self as f64) as float } /// Round half-way cases toward `infinity` - #[inline(always)] + #[inline] fn ceil(&self) -> float { ceil(*self as f64) as float } /// Round half-way cases away from `0.0` - #[inline(always)] + #[inline] fn round(&self) -> float { round(*self as f64) as float } /// The integer part of the number (rounds towards `0.0`) - #[inline(always)] + #[inline] fn trunc(&self) -> float { trunc(*self as f64) as float } /// @@ -463,81 +463,81 @@ impl Round for float { /// assert!(x == trunc(x) + fract(x)) /// ~~~ /// - #[inline(always)] + #[inline] fn fract(&self) -> float { *self - self.trunc() } } impl Fractional for float { /// The reciprocal (multiplicative inverse) of the number - #[inline(always)] + #[inline] fn recip(&self) -> float { 1.0 / *self } } impl Algebraic for float { - #[inline(always)] + #[inline] fn pow(&self, n: &float) -> float { (*self as f64).pow(&(*n as f64)) as float } - #[inline(always)] + #[inline] fn sqrt(&self) -> float { (*self as f64).sqrt() as float } - #[inline(always)] + #[inline] fn rsqrt(&self) -> float { (*self as f64).rsqrt() as float } - #[inline(always)] + #[inline] fn cbrt(&self) -> float { (*self as f64).cbrt() as float } - #[inline(always)] + #[inline] fn hypot(&self, other: &float) -> float { (*self as f64).hypot(&(*other as f64)) as float } } impl Trigonometric for float { - #[inline(always)] + #[inline] fn sin(&self) -> float { (*self as f64).sin() as float } - #[inline(always)] + #[inline] fn cos(&self) -> float { (*self as f64).cos() as float } - #[inline(always)] + #[inline] fn tan(&self) -> float { (*self as f64).tan() as float } - #[inline(always)] + #[inline] fn asin(&self) -> float { (*self as f64).asin() as float } - #[inline(always)] + #[inline] fn acos(&self) -> float { (*self as f64).acos() as float } - #[inline(always)] + #[inline] fn atan(&self) -> float { (*self as f64).atan() as float } - #[inline(always)] + #[inline] fn atan2(&self, other: &float) -> float { (*self as f64).atan2(&(*other as f64)) as float } /// Simultaneously computes the sine and cosine of the number - #[inline(always)] + #[inline] fn sin_cos(&self) -> (float, float) { match (*self as f64).sin_cos() { (s, c) => (s as float, c as float) @@ -547,54 +547,54 @@ impl Trigonometric for float { impl Exponential for float { /// Returns the exponential of the number - #[inline(always)] + #[inline] fn exp(&self) -> float { (*self as f64).exp() as float } /// Returns 2 raised to the power of the number - #[inline(always)] + #[inline] fn exp2(&self) -> float { (*self as f64).exp2() as float } /// Returns the natural logarithm of the number - #[inline(always)] + #[inline] fn ln(&self) -> float { (*self as f64).ln() as float } /// Returns the logarithm of the number with respect to an arbitrary base - #[inline(always)] + #[inline] fn log(&self, base: &float) -> float { (*self as f64).log(&(*base as f64)) as float } /// Returns the base 2 logarithm of the number - #[inline(always)] + #[inline] fn log2(&self) -> float { (*self as f64).log2() as float } /// Returns the base 10 logarithm of the number - #[inline(always)] + #[inline] fn log10(&self) -> float { (*self as f64).log10() as float } } impl Hyperbolic for float { - #[inline(always)] + #[inline] fn sinh(&self) -> float { (*self as f64).sinh() as float } - #[inline(always)] + #[inline] fn cosh(&self) -> float { (*self as f64).cosh() as float } - #[inline(always)] + #[inline] fn tanh(&self) -> float { (*self as f64).tanh() as float } @@ -608,7 +608,7 @@ impl Hyperbolic for float { /// - `self` if `self` is `0.0`, `-0.0`, `infinity`, or `neg_infinity` /// - `NaN` if `self` is `NaN` /// - #[inline(always)] + #[inline] fn asinh(&self) -> float { (*self as f64).asinh() as float } @@ -622,7 +622,7 @@ impl Hyperbolic for float { /// - `infinity` if `self` is `infinity` /// - `NaN` if `self` is `NaN` or `self < 1.0` (including `neg_infinity`) /// - #[inline(always)] + #[inline] fn acosh(&self) -> float { (*self as f64).acosh() as float } @@ -639,7 +639,7 @@ impl Hyperbolic for float { /// - `NaN` if the `self` is `NaN` or outside the domain of `-1.0 <= self <= 1.0` /// (including `infinity` and `neg_infinity`) /// - #[inline(always)] + #[inline] fn atanh(&self) -> float { (*self as f64).atanh() as float } @@ -647,157 +647,157 @@ impl Hyperbolic for float { impl Real for float { /// Archimedes' constant - #[inline(always)] + #[inline] fn pi() -> float { 3.14159265358979323846264338327950288 } /// 2.0 * pi - #[inline(always)] + #[inline] fn two_pi() -> float { 6.28318530717958647692528676655900576 } /// pi / 2.0 - #[inline(always)] + #[inline] fn frac_pi_2() -> float { 1.57079632679489661923132169163975144 } /// pi / 3.0 - #[inline(always)] + #[inline] fn frac_pi_3() -> float { 1.04719755119659774615421446109316763 } /// pi / 4.0 - #[inline(always)] + #[inline] fn frac_pi_4() -> float { 0.785398163397448309615660845819875721 } /// pi / 6.0 - #[inline(always)] + #[inline] fn frac_pi_6() -> float { 0.52359877559829887307710723054658381 } /// pi / 8.0 - #[inline(always)] + #[inline] fn frac_pi_8() -> float { 0.39269908169872415480783042290993786 } /// 1.0 / pi - #[inline(always)] + #[inline] fn frac_1_pi() -> float { 0.318309886183790671537767526745028724 } /// 2.0 / pi - #[inline(always)] + #[inline] fn frac_2_pi() -> float { 0.636619772367581343075535053490057448 } /// 2 .0/ sqrt(pi) - #[inline(always)] + #[inline] fn frac_2_sqrtpi() -> float { 1.12837916709551257389615890312154517 } /// sqrt(2.0) - #[inline(always)] + #[inline] fn sqrt2() -> float { 1.41421356237309504880168872420969808 } /// 1.0 / sqrt(2.0) - #[inline(always)] + #[inline] fn frac_1_sqrt2() -> float { 0.707106781186547524400844362104849039 } /// Euler's number - #[inline(always)] + #[inline] fn e() -> float { 2.71828182845904523536028747135266250 } /// log2(e) - #[inline(always)] + #[inline] fn log2_e() -> float { 1.44269504088896340735992468100189214 } /// log10(e) - #[inline(always)] + #[inline] fn log10_e() -> float { 0.434294481903251827651128918916605082 } /// ln(2.0) - #[inline(always)] + #[inline] fn ln_2() -> float { 0.693147180559945309417232121458176568 } /// ln(10.0) - #[inline(always)] + #[inline] fn ln_10() -> float { 2.30258509299404568401799145468436421 } /// Converts to degrees, assuming the number is in radians - #[inline(always)] + #[inline] fn to_degrees(&self) -> float { (*self as f64).to_degrees() as float } /// Converts to radians, assuming the number is in degrees - #[inline(always)] + #[inline] fn to_radians(&self) -> float { (*self as f64).to_radians() as float } } impl RealExt for float { - #[inline(always)] + #[inline] fn lgamma(&self) -> (int, float) { let mut sign = 0; let result = lgamma(*self as f64, &mut sign); (sign as int, result as float) } - #[inline(always)] + #[inline] fn tgamma(&self) -> float { tgamma(*self as f64) as float } - #[inline(always)] + #[inline] fn j0(&self) -> float { j0(*self as f64) as float } - #[inline(always)] + #[inline] fn j1(&self) -> float { j1(*self as f64) as float } - #[inline(always)] + #[inline] fn jn(&self, n: int) -> float { jn(n as c_int, *self as f64) as float } - #[inline(always)] + #[inline] fn y0(&self) -> float { y0(*self as f64) as float } - #[inline(always)] + #[inline] fn y1(&self) -> float { y1(*self as f64) as float } - #[inline(always)] + #[inline] fn yn(&self, n: int) -> float { yn(n as c_int, *self as f64) as float } } #[cfg(not(test))] impl Add<float,float> for float { - #[inline(always)] + #[inline] fn add(&self, other: &float) -> float { *self + *other } } #[cfg(not(test))] impl Sub<float,float> for float { - #[inline(always)] + #[inline] fn sub(&self, other: &float) -> float { *self - *other } } #[cfg(not(test))] impl Mul<float,float> for float { - #[inline(always)] + #[inline] fn mul(&self, other: &float) -> float { *self * *other } } #[cfg(not(test))] impl Div<float,float> for float { - #[inline(always)] + #[inline] fn div(&self, other: &float) -> float { *self / *other } } #[cfg(not(test))] impl Rem<float,float> for float { - #[inline(always)] + #[inline] fn rem(&self, other: &float) -> float { *self % *other } } #[cfg(not(test))] impl Neg<float> for float { - #[inline(always)] + #[inline] fn neg(&self) -> float { -*self } } impl Signed for float { /// Computes the absolute value. Returns `NaN` if the number is `NaN`. - #[inline(always)] + #[inline] fn abs(&self) -> float { abs(*self) } /// /// The positive difference of two numbers. Returns `0.0` if the number is less than or /// equal to `other`, otherwise the difference between`self` and `other` is returned. /// - #[inline(always)] + #[inline] fn abs_sub(&self, other: &float) -> float { (*self as f64).abs_sub(&(*other as f64)) as float } @@ -809,93 +809,93 @@ impl Signed for float { /// - `-1.0` if the number is negative, `-0.0` or `neg_infinity` /// - `NaN` if the number is NaN /// - #[inline(always)] + #[inline] fn signum(&self) -> float { if self.is_NaN() { NaN } else { f64::copysign(1.0, *self as f64) as float } } /// Returns `true` if the number is positive, including `+0.0` and `infinity` - #[inline(always)] + #[inline] fn is_positive(&self) -> bool { *self > 0.0 || (1.0 / *self) == infinity } /// Returns `true` if the number is negative, including `-0.0` and `neg_infinity` - #[inline(always)] + #[inline] fn is_negative(&self) -> bool { *self < 0.0 || (1.0 / *self) == neg_infinity } } impl Bounded for float { - #[inline(always)] + #[inline] fn min_value() -> float { Bounded::min_value::<f64>() as float } - #[inline(always)] + #[inline] fn max_value() -> float { Bounded::max_value::<f64>() as float } } impl Primitive for float { - #[inline(always)] + #[inline] fn bits() -> uint { Primitive::bits::<f64>() } - #[inline(always)] + #[inline] fn bytes() -> uint { Primitive::bytes::<f64>() } } impl Float for float { - #[inline(always)] + #[inline] fn NaN() -> float { Float::NaN::<f64>() as float } - #[inline(always)] + #[inline] fn infinity() -> float { Float::infinity::<f64>() as float } - #[inline(always)] + #[inline] fn neg_infinity() -> float { Float::neg_infinity::<f64>() as float } - #[inline(always)] + #[inline] fn neg_zero() -> float { Float::neg_zero::<f64>() as float } /// Returns `true` if the number is NaN - #[inline(always)] + #[inline] fn is_NaN(&self) -> bool { (*self as f64).is_NaN() } /// Returns `true` if the number is infinite - #[inline(always)] + #[inline] fn is_infinite(&self) -> bool { (*self as f64).is_infinite() } /// Returns `true` if the number is neither infinite or NaN - #[inline(always)] + #[inline] fn is_finite(&self) -> bool { (*self as f64).is_finite() } /// Returns `true` if the number is neither zero, infinite, subnormal or NaN - #[inline(always)] + #[inline] fn is_normal(&self) -> bool { (*self as f64).is_normal() } /// Returns the floating point category of the number. If only one property is going to /// be tested, it is generally faster to use the specific predicate instead. - #[inline(always)] + #[inline] fn classify(&self) -> FPCategory { (*self as f64).classify() } - #[inline(always)] + #[inline] fn mantissa_digits() -> uint { Float::mantissa_digits::<f64>() } - #[inline(always)] + #[inline] fn digits() -> uint { Float::digits::<f64>() } - #[inline(always)] + #[inline] fn epsilon() -> float { Float::epsilon::<f64>() as float } - #[inline(always)] + #[inline] fn min_exp() -> int { Float::min_exp::<f64>() } - #[inline(always)] + #[inline] fn max_exp() -> int { Float::max_exp::<f64>() } - #[inline(always)] + #[inline] fn min_10_exp() -> int { Float::min_10_exp::<f64>() } - #[inline(always)] + #[inline] fn max_10_exp() -> int { Float::max_10_exp::<f64>() } /// Constructs a floating point number by multiplying `x` by 2 raised to the power of `exp` - #[inline(always)] + #[inline] fn ldexp(x: float, exp: int) -> float { Float::ldexp(x as f64, exp) as float } @@ -906,7 +906,7 @@ impl Float for float { /// - `self = x * pow(2, exp)` /// - `0.5 <= abs(x) < 1.0` /// - #[inline(always)] + #[inline] fn frexp(&self) -> (float, int) { match (*self as f64).frexp() { (x, exp) => (x as float, exp) @@ -917,7 +917,7 @@ impl Float for float { /// Returns the exponential of the number, minus `1`, in a way that is accurate /// even if the number is close to zero /// - #[inline(always)] + #[inline] fn exp_m1(&self) -> float { (*self as f64).exp_m1() as float } @@ -926,7 +926,7 @@ impl Float for float { /// Returns the natural logarithm of the number plus `1` (`ln(1+n)`) more accurately /// than if the operations were performed separately /// - #[inline(always)] + #[inline] fn ln_1p(&self) -> float { (*self as f64).ln_1p() as float } @@ -936,13 +936,13 @@ impl Float for float { /// produces a more accurate result with better performance than a separate multiplication /// operation followed by an add. /// - #[inline(always)] + #[inline] fn mul_add(&self, a: float, b: float) -> float { mul_add(*self as f64, a as f64, b as f64) as float } /// Returns the next representable floating-point value in the direction of `other` - #[inline(always)] + #[inline] fn next_after(&self, other: float) -> float { next_after(*self as f64, other as f64) as float } |
