Skip to content

Commit 89af108

Browse files
committed
Rename FPCategory, FP* to FpCategory, Fp* to adhere to the naming convention
This is a [breaking-change].
1 parent dea7143 commit 89af108

File tree

9 files changed

+54
-54
lines changed

9 files changed

+54
-54
lines changed

src/libcore/fmt/float.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use char;
1818
use char::Char;
1919
use fmt;
2020
use iter::{range, DoubleEndedIteratorExt};
21-
use num::{Float, FPNaN, FPInfinite, ToPrimitive};
21+
use num::{Float, FpNan, FpInfinite, ToPrimitive};
2222
use num::cast;
2323
use result::Result::Ok;
2424
use slice::{mod, SlicePrelude};
@@ -106,11 +106,11 @@ pub fn float_to_str_bytes_common<T: Float, U>(
106106
let _1: T = Float::one();
107107

108108
match num.classify() {
109-
FPNaN => return f("NaN".as_bytes()),
110-
FPInfinite if num > _0 => {
109+
FpNan => return f("NaN".as_bytes()),
110+
FpInfinite if num > _0 => {
111111
return f("inf".as_bytes());
112112
}
113-
FPInfinite if num < _0 => {
113+
FpInfinite if num < _0 => {
114114
return f("-inf".as_bytes());
115115
}
116116
_ => {}

src/libcore/num/f32.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
use intrinsics;
2020
use mem;
21-
use num::{Float, FPNormal, FPCategory, FPZero, FPSubnormal, FPInfinite, FPNaN};
21+
use num::{Float, FpNormal, FpCategory, FpZero, FpSubnormal, FpInfinite, FpNan};
2222
use num::from_str_radix;
2323
use option::Option;
2424

@@ -156,23 +156,23 @@ impl Float for f32 {
156156
/// Returns `true` if the number is neither zero, infinite, subnormal or NaN.
157157
#[inline]
158158
fn is_normal(self) -> bool {
159-
self.classify() == FPNormal
159+
self.classify() == FpNormal
160160
}
161161

162162
/// Returns the floating point category of the number. If only one property
163163
/// is going to be tested, it is generally faster to use the specific
164164
/// predicate instead.
165-
fn classify(self) -> FPCategory {
165+
fn classify(self) -> FpCategory {
166166
const EXP_MASK: u32 = 0x7f800000;
167167
const MAN_MASK: u32 = 0x007fffff;
168168

169169
let bits: u32 = unsafe { mem::transmute(self) };
170170
match (bits & MAN_MASK, bits & EXP_MASK) {
171-
(0, 0) => FPZero,
172-
(_, 0) => FPSubnormal,
173-
(0, EXP_MASK) => FPInfinite,
174-
(_, EXP_MASK) => FPNaN,
175-
_ => FPNormal,
171+
(0, 0) => FpZero,
172+
(_, 0) => FpSubnormal,
173+
(0, EXP_MASK) => FpInfinite,
174+
(_, EXP_MASK) => FpNan,
175+
_ => FpNormal,
176176
}
177177
}
178178

src/libcore/num/f64.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
use intrinsics;
2020
use mem;
21-
use num::{Float, FPNormal, FPCategory, FPZero, FPSubnormal, FPInfinite, FPNaN};
21+
use num::{Float, FpNormal, FpCategory, FpZero, FpSubnormal, FpInfinite, FpNan};
2222
use num::from_str_radix;
2323
use option::Option;
2424

@@ -164,23 +164,23 @@ impl Float for f64 {
164164
/// Returns `true` if the number is neither zero, infinite, subnormal or NaN.
165165
#[inline]
166166
fn is_normal(self) -> bool {
167-
self.classify() == FPNormal
167+
self.classify() == FpNormal
168168
}
169169

170170
/// Returns the floating point category of the number. If only one property
171171
/// is going to be tested, it is generally faster to use the specific
172172
/// predicate instead.
173-
fn classify(self) -> FPCategory {
173+
fn classify(self) -> FpCategory {
174174
const EXP_MASK: u64 = 0x7ff0000000000000;
175175
const MAN_MASK: u64 = 0x000fffffffffffff;
176176

177177
let bits: u64 = unsafe { mem::transmute(self) };
178178
match (bits & MAN_MASK, bits & EXP_MASK) {
179-
(0, 0) => FPZero,
180-
(_, 0) => FPSubnormal,
181-
(0, EXP_MASK) => FPInfinite,
182-
(_, EXP_MASK) => FPNaN,
183-
_ => FPNormal,
179+
(0, 0) => FpZero,
180+
(_, 0) => FpSubnormal,
181+
(0, EXP_MASK) => FpInfinite,
182+
(_, EXP_MASK) => FpNan,
183+
_ => FpNormal,
184184
}
185185
}
186186

src/libcore/num/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#![stable]
1616
#![allow(missing_docs)]
1717

18-
pub use self::FPCategory::*;
18+
pub use self::FpCategory::*;
1919

2020
use {int, i8, i16, i32, i64};
2121
use {uint, u8, u16, u32, u64};
@@ -1227,20 +1227,20 @@ impl_num_cast!(f64, to_f64)
12271227
/// Used for representing the classification of floating point numbers
12281228
#[deriving(PartialEq, Show)]
12291229
#[unstable = "may be renamed"]
1230-
pub enum FPCategory {
1230+
pub enum FpCategory {
12311231
/// "Not a Number", often obtained by dividing by zero
1232-
FPNaN,
1232+
FpNan,
12331233
/// Positive or negative infinity
1234-
FPInfinite ,
1234+
FpInfinite ,
12351235
/// Positive or negative zero
1236-
FPZero,
1237-
/// De-normalized floating point representation (less precise than `FPNormal`)
1238-
FPSubnormal,
1236+
FpZero,
1237+
/// De-normalized floating point representation (less precise than `FpNormal`)
1238+
FpSubnormal,
12391239
/// A regular floating point number
1240-
FPNormal,
1240+
FpNormal,
12411241
}
12421242

1243-
impl Copy for FPCategory {}
1243+
impl Copy for FpCategory {}
12441244

12451245
/// A built-in floating point number.
12461246
// FIXME(#5527): In a future version of Rust, many of these functions will
@@ -1284,7 +1284,7 @@ pub trait Float
12841284
/// Returns true if this number is neither zero, infinite, denormal, or NaN.
12851285
fn is_normal(self) -> bool;
12861286
/// Returns the category that this number falls into.
1287-
fn classify(self) -> FPCategory;
1287+
fn classify(self) -> FpCategory;
12881288

12891289
// FIXME (#5527): These should be associated constants
12901290

src/libserialize/json.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ use std;
201201
use std::collections::{HashMap, TreeMap};
202202
use std::{char, f64, fmt, io, num, str};
203203
use std::mem::{swap, transmute};
204-
use std::num::{Float, FPNaN, FPInfinite, Int};
204+
use std::num::{Float, FpNan, FpInfinite, Int};
205205
use std::str::{FromStr, ScalarValue};
206206
use std::string;
207207
use std::vec::Vec;
@@ -389,7 +389,7 @@ fn spaces(wr: &mut io::Writer, mut n: uint) -> Result<(), io::IoError> {
389389

390390
fn fmt_number_or_null(v: f64) -> string::String {
391391
match v.classify() {
392-
FPNaN | FPInfinite => string::String::from_str("null"),
392+
FpNan | FpInfinite => string::String::from_str("null"),
393393
_ if v.fract() != 0f64 => f64::to_str_digits(v, 6u),
394394
_ => f64::to_str_digits(v, 6u) + ".0",
395395
}
@@ -2293,7 +2293,7 @@ impl ToJson for f32 {
22932293
impl ToJson for f64 {
22942294
fn to_json(&self) -> Json {
22952295
match self.classify() {
2296-
FPNaN | FPInfinite => Json::Null,
2296+
FpNan | FpInfinite => Json::Null,
22972297
_ => Json::F64(*self)
22982298
}
22992299
}

src/libstd/num/f32.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -619,14 +619,14 @@ mod tests {
619619
let neg_inf: f32 = Float::neg_infinity();
620620
let zero: f32 = Float::zero();
621621
let neg_zero: f32 = Float::neg_zero();
622-
assert_eq!(nan.classify(), FPNaN);
623-
assert_eq!(inf.classify(), FPInfinite);
624-
assert_eq!(neg_inf.classify(), FPInfinite);
625-
assert_eq!(zero.classify(), FPZero);
626-
assert_eq!(neg_zero.classify(), FPZero);
627-
assert_eq!(1f32.classify(), FPNormal);
628-
assert_eq!(1e-37f32.classify(), FPNormal);
629-
assert_eq!(1e-38f32.classify(), FPSubnormal);
622+
assert_eq!(nan.classify(), FpNan);
623+
assert_eq!(inf.classify(), FpInfinite);
624+
assert_eq!(neg_inf.classify(), FpInfinite);
625+
assert_eq!(zero.classify(), FpZero);
626+
assert_eq!(neg_zero.classify(), FpZero);
627+
assert_eq!(1f32.classify(), FpNormal);
628+
assert_eq!(1e-37f32.classify(), FpNormal);
629+
assert_eq!(1e-38f32.classify(), FpSubnormal);
630630
}
631631

632632
#[test]

src/libstd/num/f64.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -622,13 +622,13 @@ mod tests {
622622
let neg_inf: f64 = Float::neg_infinity();
623623
let zero: f64 = Float::zero();
624624
let neg_zero: f64 = Float::neg_zero();
625-
assert_eq!(nan.classify(), FPNaN);
626-
assert_eq!(inf.classify(), FPInfinite);
627-
assert_eq!(neg_inf.classify(), FPInfinite);
628-
assert_eq!(zero.classify(), FPZero);
629-
assert_eq!(neg_zero.classify(), FPZero);
630-
assert_eq!(1e-307f64.classify(), FPNormal);
631-
assert_eq!(1e-308f64.classify(), FPSubnormal);
625+
assert_eq!(nan.classify(), FpNan);
626+
assert_eq!(inf.classify(), FpInfinite);
627+
assert_eq!(neg_inf.classify(), FpInfinite);
628+
assert_eq!(zero.classify(), FpZero);
629+
assert_eq!(neg_zero.classify(), FpZero);
630+
assert_eq!(1e-307f64.classify(), FpNormal);
631+
assert_eq!(1e-308f64.classify(), FpSubnormal);
632632
}
633633

634634
#[test]

src/libstd/num/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ pub use core::num::{from_int, from_i8, from_i16, from_i32, from_i64};
3030
pub use core::num::{from_uint, from_u8, from_u16, from_u32, from_u64};
3131
pub use core::num::{from_f32, from_f64};
3232
pub use core::num::{FromStrRadix, from_str_radix};
33-
pub use core::num::{FPCategory, FPNaN, FPInfinite, FPZero, FPSubnormal};
34-
pub use core::num::{FPNormal, Float};
33+
pub use core::num::{FpCategory, FpNan, FpInfinite, FpZero, FpSubnormal};
34+
pub use core::num::{FpNormal, Float};
3535

3636
#[experimental = "may be removed or relocated"]
3737
pub mod strconv;

src/libstd/num/strconv.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use char;
2020
use char::Char;
2121
use kinds::Copy;
2222
use num;
23-
use num::{Int, Float, FPNaN, FPInfinite, ToPrimitive};
23+
use num::{Int, Float, FpNan, FpInfinite, ToPrimitive};
2424
use slice::{SlicePrelude, CloneSliceAllocPrelude};
2525
use str::StrPrelude;
2626
use string::String;
@@ -207,14 +207,14 @@ pub fn float_to_str_bytes_common<T: Float>(
207207
let _1: T = Float::one();
208208

209209
match num.classify() {
210-
FPNaN => { return (b"NaN".to_vec(), true); }
211-
FPInfinite if num > _0 => {
210+
FpNan => { return (b"NaN".to_vec(), true); }
211+
FpInfinite if num > _0 => {
212212
return match sign {
213213
SignAll => (b"+inf".to_vec(), true),
214214
_ => (b"inf".to_vec(), true)
215215
};
216216
}
217-
FPInfinite if num < _0 => {
217+
FpInfinite if num < _0 => {
218218
return match sign {
219219
SignNone => (b"inf".to_vec(), true),
220220
_ => (b"-inf".to_vec(), true),

0 commit comments

Comments
 (0)