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

Feature request: Compare floats and have NaN be true #852

Open
r-barnes opened this issue May 15, 2024 · 1 comment
Open

Feature request: Compare floats and have NaN be true #852

r-barnes opened this issue May 15, 2024 · 1 comment

Comments

@r-barnes
Copy link

Description

When I take

CHECK(floating_value1 == floating_value2);

it would be nice to have a way to say "have the check pass if the values are equal or the floats are both NaN".

@dargueta
Copy link

If you're using C++11 or higher, you can use std::isnan() defined in the standard cmath header, like so:

CHECK((v1 == v2) || (std::isnan(v1) && std::isnan(v2));

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