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

Possible logic error in Floating-point Comparison function #5

Closed
linomp opened this issue Feb 18, 2023 · 1 comment
Closed

Possible logic error in Floating-point Comparison function #5

linomp opened this issue Feb 18, 2023 · 1 comment

Comments

@linomp
Copy link

linomp commented Feb 18, 2023

In 02.Basic_Concepts_I.pdf, on slide 94 inside the function areFloatNearlyEqual there is the following code for catching Inf or NaN arguments:

if (std::isfinite(a) || isfinite(b))  // a = ±∞, b = ±∞ and NaN
        return false;

But it was causing the function to return false always, even for finite values. I think it should be:

if (!(std::isfinite(a) && std::isfinite(b)))  // a = ±∞, b = ±∞ and NaN
        return false;
@federico-busato
Copy link
Owner

thank you, @linomp!! I will fix it in the next release.

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