Skip to content

Possible logic error in Floating-point Comparison function #5

@linomp

Description

@linomp

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions