diff options
| author | Aaron Turon <aturon@mozilla.com> | 2014-04-24 17:09:58 -0700 |
|---|---|---|
| committer | Aaron Turon <aturon@mozilla.com> | 2014-04-24 17:13:33 -0700 |
| commit | b8da4d7704fc71c5cb97eb42459bc6d847e96ea6 (patch) | |
| tree | 6a5ba3ff9b83364ffc59dee834f4b77af4510fda /src/libstd/num/f32.rs | |
| parent | b55394415ab63adf32036f63595f3bba3e1c9098 (diff) | |
| download | rust-b8da4d7704fc71c5cb97eb42459bc6d847e96ea6.tar.gz rust-b8da4d7704fc71c5cb97eb42459bc6d847e96ea6.zip | |
add min_pos_value constant for floats
Follow-up on issue #13297 and PR #13710. Instead of following the (confusing) C/C++ approach of using `MIN_VALUE` for the smallest *positive* number, we introduce `MIN_POS_VALUE` (and in the Float trait, `min_pos_value`) to represent this number. This patch also removes a few remaining redundantly-defined constants that were missed last time around.
Diffstat (limited to 'src/libstd/num/f32.rs')
| -rw-r--r-- | src/libstd/num/f32.rs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index 6df549dbc79..36e5728200b 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -71,9 +71,11 @@ pub static DIGITS: uint = 6u; pub static EPSILON: f32 = 1.19209290e-07_f32; -/// Minimum normalized f32 value -pub static MIN_VALUE: f32 = 1.17549435e-38_f32; -/// Maximum f32 value +/// Smallest finite f32 value +pub static MIN_VALUE: f32 = -3.40282347e+38_f32; +/// Smallest positive, normalized f32 value +pub static MIN_POS_VALUE: f32 = 1.17549435e-38_f32; +/// Largest finite f32 value pub static MAX_VALUE: f32 = 3.40282347e+38_f32; pub static MIN_EXP: int = -125; @@ -90,8 +92,9 @@ pub static NEG_INFINITY: f32 = -1.0_f32/0.0_f32; pub mod consts { // FIXME: replace with mathematical constants from cmath. - // FIXME(#11621): These constants should be deprecated once CTFE is - // implemented in favour of calling their respective functions in `Float`. + // FIXME(#5527): These constants should be deprecated once associated + // constants are implemented in favour of referencing the respective members + // of `Float`. /// Archimedes' constant pub static PI: f32 = 3.14159265358979323846264338327950288_f32; @@ -342,6 +345,9 @@ impl Float for f32 { #[inline] fn max_10_exp(_: Option<f32>) -> int { MAX_10_EXP } + #[inline] + fn min_pos_value(_: Option<f32>) -> f32 { MIN_POS_VALUE } + /// Constructs a floating point number by multiplying `x` by 2 raised to the /// power of `exp` #[inline] |
