Skip to content

RunTests::check_if_equal for floats/doubles cannot distinguish between relative and absolute error #202

Description

@KrisThielemans

After fixing #183 at PR #198, we now do

    const double diff = fabs(b-a);
    if (diff <= tolerance)
            return true;

    const double largest = (std::max(fabs(b), fabs(a)));
    return ( diff <= tolerance*largest);

However, in many cases for floats, you might just want to do a relative error, where the 2 tolerances really could have very different values.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions