Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jun 3, 2018

Conversation

frewsxcv
Copy link
Member

@frewsxcv frewsxcv commented May 20, 2018

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

@pietroalbini pietroalbini added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 21, 2018
@pietroalbini
Copy link
Member

r? @steveklabnik (someone from docs)

@pietroalbini
Copy link
Member

Ping from triage @steveklabnik! This PR needs your review.

Copy link
Member

@steveklabnik steveklabnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This change is great, but the format is

/// Summary sentence.
///
/// longer explanation goes here

So, just a small formatting change, and this is good to go. Thank you!

@@ -33,7 +33,10 @@ 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`. Difference between `1.0` and the next
/// largest representable number.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change this to

/// [Machine epsilon] value for `f32`.
///
/// This is the difference between `1.0` and the next largest representable number.

/// [Machine epsilon] value for `f64`. Difference between `1.0` and the next
/// largest representable number.
///
/// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and same here

@frewsxcv frewsxcv dismissed steveklabnik’s stale review May 28, 2018 13:29

comments addressed in the latest force push

@frewsxcv
Copy link
Member Author

frewsxcv commented Jun 2, 2018

@bors r=steveklabnik rollup

@bors
Copy link
Contributor

bors commented Jun 2, 2018

📌 Commit 12878a7 has been approved by steveklabnik

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 2, 2018
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request Jun 2, 2018
…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
bors added a commit that referenced this pull request Jun 2, 2018
Rollup of 6 pull requests

Successful merges:

 - #50167 ( Add as_nanos function to Duration)
 - #50919 (Provide more context for what the {f32,f64}::EPSILON values represent.)
 - #51124 (Reword {ptr,mem}::replace docs.)
 - #51147 (Stabilize SliceIndex trait.)
 - #51291 (Fix typos of ‘ambiguous’)
 - #51302 (Permit building rustdoc without compiler artifacts)

Failed merges:
@bors bors merged commit 12878a7 into rust-lang:master Jun 3, 2018
/// 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me this does not parse correctly. Epsilon is the number which when added to 1.0 will yield a different number than 1.0. This sounds more correct to me:

This is the difference between 1.0 and the next smallest representable number.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be clearer if it was "next larger representable number"? The usage of "large" is to indicate it's in the positive direction (above 1.0). Maybe it's sufficient to just say "next representable number"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@frewsxcv Yes, both would work for me. I'm not a mathematician but if I remember correctly the direction doesn't even matter.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The direction does matter because floating point numbers < 1 have a smaller exponent (due to normalization) and therefore are more dense than those >= 1. The "epsilon" in the other direction would be half of the one in the positive direction.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rkruppe Oh right, I forgot about normalisation. Thanks for the reminder.

@frewsxcv frewsxcv deleted the frewsxcv-epsilon branch June 3, 2018 19:37
RalfJung added a commit to RalfJung/rust that referenced this pull request Nov 29, 2019
Clarify `{f32,f64}::EPSILON` docs

The doc for `EPSILON` says:
>  This is the difference between `1.0` and the next **largest** representable number.

Which is a bit unclear.

[Wikipedia](https://en.wikipedia.org/wiki/Machine_epsilon) says
> Machine epsilon is defined as the difference between 1 and the next **larger** floating point number

So this PR update the docs to match the Wikipedia version.

The original PR also has this in a [comment](rust-lang#50919 (comment)).
RalfJung added a commit to RalfJung/rust that referenced this pull request Nov 29, 2019
Clarify `{f32,f64}::EPSILON` docs

The doc for `EPSILON` says:
>  This is the difference between `1.0` and the next **largest** representable number.

Which is a bit unclear.

[Wikipedia](https://en.wikipedia.org/wiki/Machine_epsilon) says
> Machine epsilon is defined as the difference between 1 and the next **larger** floating point number

So this PR update the docs to match the Wikipedia version.

The original PR also has this in a [comment](rust-lang#50919 (comment)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants