Skip to content

Commit

Permalink
Rollup merge of rust-lang#50919 - frewsxcv:frewsxcv-epsilon, r=stevek…
Browse files Browse the repository at this point in the history
…labnik

Provide more context for what the {f32,f64}::EPSILON values represent.

Introduce the 'machine epsilon' term because if one googles 'epsilon', they might stumble upon https://en.wikipedia.org/wiki/Epsilon_numbers_(mathematics) instead of https://en.wikipedia.org/wiki/Machine_epsilon
  • Loading branch information
Mark-Simulacrum committed Jun 2, 2018
2 parents 77c8bd0 + 12878a7 commit 6ff9108
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/libcore/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ pub const MANTISSA_DIGITS: u32 = 24;
#[stable(feature = "rust1", since = "1.0.0")]
pub const DIGITS: u32 = 6;

/// Difference between `1.0` and the next largest representable number.
/// [Machine epsilon] value for `f32`.
///
/// This is the difference between `1.0` and the next largest representable number.
///
/// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon
#[stable(feature = "rust1", since = "1.0.0")]
pub const EPSILON: f32 = 1.19209290e-07_f32;

Expand Down
6 changes: 5 additions & 1 deletion src/libcore/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ pub const MANTISSA_DIGITS: u32 = 53;
#[stable(feature = "rust1", since = "1.0.0")]
pub const DIGITS: u32 = 15;

/// Difference between `1.0` and the next largest representable number.
/// [Machine epsilon] value for `f64`.
///
/// This is the difference between `1.0` and the next largest representable number.
///
/// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon
#[stable(feature = "rust1", since = "1.0.0")]
pub const EPSILON: f64 = 2.2204460492503131e-16_f64;

Expand Down

0 comments on commit 6ff9108

Please sign in to comment.