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

approx_constant "Known problems" section is incorrect #4025

Closed
kraai opened this issue Apr 24, 2019 · 2 comments · Fixed by #4027
Closed

approx_constant "Known problems" section is incorrect #4025

kraai opened this issue Apr 24, 2019 · 2 comments · Fixed by #4027
Labels
A-documentation Area: Adding or improving documentation good-first-issue These issues are a good way to get started with Clippy

Comments

@kraai
Copy link
Contributor

kraai commented Apr 24, 2019

The documentation for approx_constant says in the "Known problems" section:

If you happen to have a value that is within 1/8192 of a known constant, but is not and should not be the same, this lint will report your value anyway. We have not yet noticed any false positives in code we tested clippy with (this includes servo), but YMMV.

The function that compares the values has the following header comment:

/// Returns `false` if the number of significant figures in `value` are                                                                               
/// less than `min_digits`; otherwise, returns true if `value` is equal                                                                               
/// to `constant`, rounded to the number of digits present in `value`.                                                                                

There's nothing in that comment, or that I can see in the code, referring to 1/8192, so I think the documentation is incorrect.

@flip1995
Copy link
Member

I don't really know where the number 1/8192(=2^-13) is coming from. I assume it comes from the precision of float numbers expressed in decimal digits.

cc @llogiq wrote the lint and documentation ~4 years ago. Maybe he can shed some light onto this magic number.

@flip1995
Copy link
Member

In the initial implementation there was a magic EPSILON_DIVISOR constant:

const EPSILON_DIVISOR : f64 = 8192f64; //TODO: test to find a good value
(old like from 09/2015)

This constant was removed in #408 and I think this Known Problems is not an issue anymore.

@flip1995 flip1995 added good-first-issue These issues are a good way to get started with Clippy A-documentation Area: Adding or improving documentation labels Apr 24, 2019
kraai added a commit to kraai/rust-clippy that referenced this issue Apr 24, 2019
bors added a commit that referenced this issue Apr 24, 2019
…phansch

Remove approx_constant known problems

Fixes #4025.

changelog: Remove `approx_constant`'s documentation's "Known problems" section.
bors added a commit that referenced this issue Apr 24, 2019
…phansch

Remove approx_constant known problems

Fixes #4025.

changelog: Remove `approx_constant`'s documentation's "Known problems" section.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-documentation Area: Adding or improving documentation good-first-issue These issues are a good way to get started with Clippy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants