Skip to content

Unexpected result of fuzzy_eq() on large number #5316

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

Closed
ILyoan opened this issue Mar 11, 2013 · 3 comments · Fixed by #11402
Closed

Unexpected result of fuzzy_eq() on large number #5316

ILyoan opened this issue Mar 11, 2013 · 3 comments · Fixed by #11402

Comments

@ILyoan
Copy link
Contributor

ILyoan commented Mar 11, 2013

fuzzy_eq() is well working with small float numbers but when the number become too large that even the round-off error exceed the epsilon(default is 1e-6), the function can return an unexpected result.

See this
https://gist.github.com/ILyoan/5136141
fuzzy_eq() in 21th line will return false because
27272727272727276822 = 1e20 * (1/11) * 3
27272727272727272406 = 1e20 * (3/11)
and the difference between two numbers is larger than default epsilon

How about we use relative error method like this
https://gist.github.com/ILyoan/5136153

@lifthrasiir
Copy link
Contributor

We can also use an ulp-based approach, like Google's C++ testing framework.

@metajack
Copy link
Contributor

nominating production ready

@graydon
Copy link
Contributor

graydon commented Aug 8, 2013

accepted for production-ready milestone

@bors bors closed this as completed in ab9ec6d Jan 9, 2014
bors added a commit to rust-lang-ci/rust that referenced this issue May 2, 2020
Don't convert Path to lossy str

changelog: none
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

Successfully merging a pull request may close this issue.

4 participants