Skip to content

Commit e4a9eb9

Browse files
committed
Remove _VALUE from the float extremes constants.
In `std::f32` and `std::f64`: - `MIN_VALUE` → `MIN` - `MAX_VALUE` → `MAX` - `MIN_POS_VALUE` → `MIN_POSITIVE` This matches the corresponding integer constants. [breaking-change]
1 parent 39b463f commit e4a9eb9

File tree

6 files changed

+41
-13
lines changed

6 files changed

+41
-13
lines changed

src/libcore/num/f32.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,27 @@ pub const EPSILON: f32 = 1.19209290e-07_f32;
3535

3636
/// Smallest finite f32 value
3737
#[stable(feature = "rust1", since = "1.0.0")]
38+
#[deprecated(since = "1.0.0", reason = "use `std::f32::MIN`")]
3839
pub const MIN_VALUE: f32 = -3.40282347e+38_f32;
3940
/// Smallest positive, normalized f32 value
4041
#[stable(feature = "rust1", since = "1.0.0")]
42+
#[deprecated(since = "1.0.0", reason = "use `std::f32::MIN_POSITIVE`")]
4143
pub const MIN_POS_VALUE: f32 = 1.17549435e-38_f32;
4244
/// Largest finite f32 value
4345
#[stable(feature = "rust1", since = "1.0.0")]
46+
#[deprecated(since = "1.0.0", reason = "use `std::f32::MAX`")]
4447
pub const MAX_VALUE: f32 = 3.40282347e+38_f32;
4548

49+
/// Smallest finite f32 value
50+
#[stable(feature = "rust1", since = "1.0.0")]
51+
pub const MIN: f32 = -3.40282347e+38_f32;
52+
/// Smallest positive, normalized f32 value
53+
#[stable(feature = "rust1", since = "1.0.0")]
54+
pub const MIN_POSITIVE: f32 = 1.17549435e-38_f32;
55+
/// Largest finite f32 value
56+
#[stable(feature = "rust1", since = "1.0.0")]
57+
pub const MAX: f32 = 3.40282347e+38_f32;
58+
4659
#[unstable(feature = "core", reason = "pending integer conventions")]
4760
pub const MIN_EXP: int = -125;
4861
#[unstable(feature = "core", reason = "pending integer conventions")]
@@ -215,17 +228,17 @@ impl Float for f32 {
215228
#[inline]
216229
#[unstable(feature = "core")]
217230
#[deprecated(since = "1.0.0")]
218-
fn min_value() -> f32 { MIN_VALUE }
231+
fn min_value() -> f32 { MIN }
219232

220233
#[inline]
221234
#[unstable(feature = "core")]
222235
#[deprecated(since = "1.0.0")]
223-
fn min_pos_value(_: Option<f32>) -> f32 { MIN_POS_VALUE }
236+
fn min_pos_value(_: Option<f32>) -> f32 { MIN_POSITIVE }
224237

225238
#[inline]
226239
#[unstable(feature = "core")]
227240
#[deprecated(since = "1.0.0")]
228-
fn max_value() -> f32 { MAX_VALUE }
241+
fn max_value() -> f32 { MAX }
229242

230243
/// Returns the mantissa, exponent and sign as integers.
231244
fn integer_decode(self) -> (u64, i16, i8) {

src/libcore/num/f64.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,27 @@ pub const EPSILON: f64 = 2.2204460492503131e-16_f64;
3838

3939
/// Smallest finite f64 value
4040
#[stable(feature = "rust1", since = "1.0.0")]
41+
#[deprecated(since = "1.0.0", reason = "use `std::f64::MIN`")]
4142
pub const MIN_VALUE: f64 = -1.7976931348623157e+308_f64;
4243
/// Smallest positive, normalized f64 value
4344
#[stable(feature = "rust1", since = "1.0.0")]
45+
#[deprecated(since = "1.0.0", reason = "use `std::f64::MIN_POSITIVE`")]
4446
pub const MIN_POS_VALUE: f64 = 2.2250738585072014e-308_f64;
4547
/// Largest finite f64 value
4648
#[stable(feature = "rust1", since = "1.0.0")]
49+
#[deprecated(since = "1.0.0", reason = "use `std::f64::MAX`")]
4750
pub const MAX_VALUE: f64 = 1.7976931348623157e+308_f64;
4851

52+
/// Smallest finite f64 value
53+
#[stable(feature = "rust1", since = "1.0.0")]
54+
pub const MIN: f64 = -1.7976931348623157e+308_f64;
55+
/// Smallest positive, normalized f64 value
56+
#[stable(feature = "rust1", since = "1.0.0")]
57+
pub const MIN_POSITIVE: f64 = 2.2250738585072014e-308_f64;
58+
/// Largest finite f64 value
59+
#[stable(feature = "rust1", since = "1.0.0")]
60+
pub const MAX: f64 = 1.7976931348623157e+308_f64;
61+
4962
#[unstable(feature = "core", reason = "pending integer conventions")]
5063
pub const MIN_EXP: int = -1021;
5164
#[unstable(feature = "core", reason = "pending integer conventions")]
@@ -222,17 +235,17 @@ impl Float for f64 {
222235
#[inline]
223236
#[unstable(feature = "core")]
224237
#[deprecated(since = "1.0.0")]
225-
fn min_value() -> f64 { MIN_VALUE }
238+
fn min_value() -> f64 { MIN }
226239

227240
#[inline]
228241
#[unstable(feature = "core")]
229242
#[deprecated(since = "1.0.0")]
230-
fn min_pos_value(_: Option<f64>) -> f64 { MIN_POS_VALUE }
243+
fn min_pos_value(_: Option<f64>) -> f64 { MIN_POSITIVE }
231244

232245
#[inline]
233246
#[unstable(feature = "core")]
234247
#[deprecated(since = "1.0.0")]
235-
fn max_value() -> f64 { MAX_VALUE }
248+
fn max_value() -> f64 { MAX }
236249

237250
/// Returns the mantissa, exponent and sign as integers.
238251
fn integer_decode(self) -> (u64, i16, i8) {

src/libcore/num/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ macro_rules! impl_to_primitive_float_to_float {
956956
Some($slf as $DstT)
957957
} else {
958958
let n = $slf as f64;
959-
let max_value: $SrcT = ::$SrcT::MAX_VALUE;
959+
let max_value: $SrcT = ::$SrcT::MAX;
960960
if -max_value as f64 <= n && n <= max_value as f64 {
961961
Some($slf as $DstT)
962962
} else {
@@ -1331,18 +1331,18 @@ pub trait Float
13311331
/// Returns the smallest finite value that this type can represent.
13321332
#[unstable(feature = "core")]
13331333
#[deprecated(since = "1.0.0",
1334-
reason = "use `std::f32::MIN_VALUE` or `std::f64::MIN_VALUE` as appropriate")]
1334+
reason = "use `std::f32::MIN` or `std::f64::MIN` as appropriate")]
13351335
fn min_value() -> Self;
13361336
/// Returns the smallest normalized positive number that this type can represent.
13371337
#[unstable(feature = "core")]
13381338
#[deprecated(since = "1.0.0",
1339-
reason = "use `std::f32::MIN_POS_VALUE` or \
1340-
`std::f64::MIN_POS_VALUE` as appropriate")]
1339+
reason = "use `std::f32::MIN_POSITIVE` or \
1340+
`std::f64::MIN_POSITIVE` as appropriate")]
13411341
fn min_pos_value(unused_self: Option<Self>) -> Self;
13421342
/// Returns the largest finite value that this type can represent.
13431343
#[unstable(feature = "core")]
13441344
#[deprecated(since = "1.0.0",
1345-
reason = "use `std::f32::MAX_VALUE` or `std::f64::MAX_VALUE` as appropriate")]
1345+
reason = "use `std::f32::MAX` or `std::f64::MAX` as appropriate")]
13461346
fn max_value() -> Self;
13471347

13481348
/// Returns true if this value is NaN and false otherwise.

src/librustc/lint/builtin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ impl LintPass for TypeLimits {
318318

319319
fn float_ty_range(float_ty: ast::FloatTy) -> (f64, f64) {
320320
match float_ty {
321-
ast::TyF32 => (f32::MIN_VALUE as f64, f32::MAX_VALUE as f64),
322-
ast::TyF64 => (f64::MIN_VALUE, f64::MAX_VALUE)
321+
ast::TyF32 => (f32::MIN as f64, f32::MAX as f64),
322+
ast::TyF64 => (f64::MIN, f64::MAX)
323323
}
324324
}
325325

src/libstd/num/f32.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use core::num;
3030
pub use core::f32::{RADIX, MANTISSA_DIGITS, DIGITS, EPSILON, MIN_VALUE};
3131
pub use core::f32::{MIN_POS_VALUE, MAX_VALUE, MIN_EXP, MAX_EXP, MIN_10_EXP};
3232
pub use core::f32::{MAX_10_EXP, NAN, INFINITY, NEG_INFINITY};
33+
pub use core::f32::{MIN, MIN_POSITIVE, MAX};
3334
pub use core::f32::consts;
3435

3536
#[allow(dead_code)]

src/libstd/num/f64.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use core::num;
2929
pub use core::f64::{RADIX, MANTISSA_DIGITS, DIGITS, EPSILON, MIN_VALUE};
3030
pub use core::f64::{MIN_POS_VALUE, MAX_VALUE, MIN_EXP, MAX_EXP, MIN_10_EXP};
3131
pub use core::f64::{MAX_10_EXP, NAN, INFINITY, NEG_INFINITY};
32+
pub use core::f64::{MIN, MIN_POSITIVE, MAX};
3233
pub use core::f64::consts;
3334

3435
#[allow(dead_code)]

0 commit comments

Comments
 (0)