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

bug: checking against NaN is always false #5

Open
conradsnicta opened this issue Sep 2, 2019 · 0 comments
Open

bug: checking against NaN is always false #5

conradsnicta opened this issue Sep 2, 2019 · 0 comments

Comments

@conradsnicta
Copy link

The following statement in fastplm.cpp always evaluates to false:

if (coef(i) == arma::datum::nan) {

According to the documentation for std::numeric_limits::quiet_NaN()

A NaN never compares equal to itself.

Armadillo uses std::numeric_limits<T>::quiet_NaN() for datum::nan, so the same caveat applies.

To fix this, use std::isnan() instead:
if (std::isnan(coef(i))) {

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

1 participant