diff options
| author | bors <bors@rust-lang.org> | 2014-12-23 22:21:10 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-12-23 22:21:10 +0000 |
| commit | 96a3c7c6a051ab2f5fc01fe9e686f7fffcc87c61 (patch) | |
| tree | 05688fe976620a03dd2a3ef37f4a82d0dcca3825 /src/libcore | |
| parent | d10642ef0f8976b9fb08500acdff84e3990815fa (diff) | |
| parent | 16f01cc13f6a092873096c44eed546561b88d245 (diff) | |
| download | rust-96a3c7c6a051ab2f5fc01fe9e686f7fffcc87c61.tar.gz rust-96a3c7c6a051ab2f5fc01fe9e686f7fffcc87c61.zip | |
auto merge of #19758 : tbu-/rust/pr_fp_name, r=alexcrichton
This is a [breaking-change].
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/fmt/float.rs | 10 | ||||
| -rw-r--r-- | src/libcore/num/f32.rs | 17 | ||||
| -rw-r--r-- | src/libcore/num/f64.rs | 17 | ||||
| -rw-r--r-- | src/libcore/num/mod.rs | 18 |
4 files changed, 31 insertions, 31 deletions
diff --git a/src/libcore/fmt/float.rs b/src/libcore/fmt/float.rs index 9ab450efd22..55a87973e0f 100644 --- a/src/libcore/fmt/float.rs +++ b/src/libcore/fmt/float.rs @@ -18,8 +18,8 @@ use char; use char::Char; use fmt; use iter::{range, DoubleEndedIteratorExt}; -use num::{Float, FPNaN, FPInfinite, ToPrimitive}; -use num::cast; +use num::{cast, Float, ToPrimitive}; +use num::FpCategory as Fp; use ops::FnOnce; use result::Result::Ok; use slice::{mod, SliceExt}; @@ -109,11 +109,11 @@ pub fn float_to_str_bytes_common<T: Float, U, F>( let _1: T = Float::one(); match num.classify() { - FPNaN => return f("NaN".as_bytes()), - FPInfinite if num > _0 => { + Fp::Nan => return f("NaN".as_bytes()), + Fp::Infinite if num > _0 => { return f("inf".as_bytes()); } - FPInfinite if num < _0 => { + Fp::Infinite if num < _0 => { return f("-inf".as_bytes()); } _ => {} diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index add42a2ddce..d8b22a085aa 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -18,7 +18,8 @@ use intrinsics; use mem; -use num::{Float, FPNormal, FPCategory, FPZero, FPSubnormal, FPInfinite, FPNaN}; +use num::Float; +use num::FpCategory as Fp; use num::from_str_radix; use option::Option; @@ -156,23 +157,23 @@ impl Float for f32 { /// Returns `true` if the number is neither zero, infinite, subnormal or NaN. #[inline] fn is_normal(self) -> bool { - self.classify() == FPNormal + self.classify() == Fp::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. - fn classify(self) -> FPCategory { + fn classify(self) -> Fp { const EXP_MASK: u32 = 0x7f800000; const MAN_MASK: u32 = 0x007fffff; let bits: u32 = unsafe { mem::transmute(self) }; match (bits & MAN_MASK, bits & EXP_MASK) { - (0, 0) => FPZero, - (_, 0) => FPSubnormal, - (0, EXP_MASK) => FPInfinite, - (_, EXP_MASK) => FPNaN, - _ => FPNormal, + (0, 0) => Fp::Zero, + (_, 0) => Fp::Subnormal, + (0, EXP_MASK) => Fp::Infinite, + (_, EXP_MASK) => Fp::Nan, + _ => Fp::Normal, } } diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index 12c0771d0b9..a3f5c2df91f 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -18,7 +18,8 @@ use intrinsics; use mem; -use num::{Float, FPNormal, FPCategory, FPZero, FPSubnormal, FPInfinite, FPNaN}; +use num::Float; +use num::FpCategory as Fp; use num::from_str_radix; use option::Option; @@ -164,23 +165,23 @@ impl Float for f64 { /// Returns `true` if the number is neither zero, infinite, subnormal or NaN. #[inline] fn is_normal(self) -> bool { - self.classify() == FPNormal + self.classify() == Fp::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. - fn classify(self) -> FPCategory { + fn classify(self) -> Fp { const EXP_MASK: u64 = 0x7ff0000000000000; const MAN_MASK: u64 = 0x000fffffffffffff; let bits: u64 = unsafe { mem::transmute(self) }; match (bits & MAN_MASK, bits & EXP_MASK) { - (0, 0) => FPZero, - (_, 0) => FPSubnormal, - (0, EXP_MASK) => FPInfinite, - (_, EXP_MASK) => FPNaN, - _ => FPNormal, + (0, 0) => Fp::Zero, + (_, 0) => Fp::Subnormal, + (0, EXP_MASK) => Fp::Infinite, + (_, EXP_MASK) => Fp::Nan, + _ => Fp::Normal, } } diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 60735879213..0d2ce4f6071 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -15,8 +15,6 @@ #![stable] #![allow(missing_docs)] -pub use self::FPCategory::*; - use {int, i8, i16, i32, i64}; use {uint, u8, u16, u32, u64}; use {f32, f64}; @@ -1222,17 +1220,17 @@ impl_num_cast! { f64, to_f64 } /// Used for representing the classification of floating point numbers #[deriving(Copy, PartialEq, Show)] #[unstable = "may be renamed"] -pub enum FPCategory { +pub enum FpCategory { /// "Not a Number", often obtained by dividing by zero - FPNaN, + Nan, /// Positive or negative infinity - FPInfinite , + Infinite , /// Positive or negative zero - FPZero, - /// De-normalized floating point representation (less precise than `FPNormal`) - FPSubnormal, + Zero, + /// De-normalized floating point representation (less precise than `Normal`) + Subnormal, /// A regular floating point number - FPNormal, + Normal, } /// A built-in floating point number. @@ -1277,7 +1275,7 @@ pub trait Float /// Returns true if this number is neither zero, infinite, denormal, or NaN. fn is_normal(self) -> bool; /// Returns the category that this number falls into. - fn classify(self) -> FPCategory; + fn classify(self) -> FpCategory; // FIXME (#5527): These should be associated constants |
