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

Clippy suggests incorrect expression for mul_add #4751

Closed
95th opened this issue Oct 29, 2019 · 3 comments
Closed

Clippy suggests incorrect expression for mul_add #4751

95th opened this issue Oct 29, 2019 · 3 comments

Comments

@95th
Copy link

95th commented Oct 29, 2019

clippy suggests incorrect expression:

warning: consider using mul_add() for better numerical precision
  --> src/jarowinkler.rs:68:9
   |
68 |         j + 0.1 * p * (1.0 - j)
   |         ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `0.1 * p.mul_add((1.0 - j), j)`
   |
   = note: `#[warn(clippy::manual_mul_add)]` on by default
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_mul_add

Isn't suggested expression 0.1 * p.mul_add((1.0 - j), j) equivalent to:

0.1 * (p * (1.0 - j) + j)

which is not equivalent to original formula.

Perhaps it should suggest:

(0.1 * p).mul_add((1.0 - j), j)

Additional info:

$ cargo clippy --version
clippy 0.0.212 (8ab24d7 2019-10-24)
@flip1995
Copy link
Member

Duplicate of #4735

@flip1995 flip1995 marked this as a duplicate of #4735 Oct 29, 2019
@flip1995
Copy link
Member

We also moved it to nursery, so it is allow-by-default with the next nightly

@95th
Copy link
Author

95th commented Oct 29, 2019

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants