We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi
almostEqual tests for absolute tolerance such that small values are always considered equal whereas big values are not.
almostEqual
With actual function
function almostEqual (left, right, tol) { return Math.abs(left - right) <= tol }
the tests will pass when left === tol and right === 0 which may be weird, but is will not pass for big numbers.
Instead,
function almostEqual (left, right, tol) { return Math.abs(left - right) <= tol * (Math.abs(left)+Math.abs(right)+1) // the +1 for small }
will pass only on rounding errors, whatever the magnitude of arguments is, either known in advance or not.
Thanks
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi
almostEqual
tests for absolute tolerance such that small values are always considered equal whereas big values are not.With actual function
the tests will pass when left === tol and right === 0 which may be weird, but is will not pass for big numbers.
Instead,
will pass only on rounding errors, whatever the magnitude of arguments is, either known in advance or not.
Thanks
The text was updated successfully, but these errors were encountered: