At first it looks like a legacy code and sloppy programming to me. IsNaN, depending on configuration (my guess) is either calling std::isnan, which has the return type bool, or ROOT::Math::Internal::IsNan, which requires R__FAST_MATH and after pretending being smart and fast and whatever … converts an essentially bool expression into this Int_t for the reason that is unknown.
Maybe, they first were using isnan from C headers (which seems to be a macro there, since C does not have overloading and in my implementation, for example, resolves to something like
__header_always_inline int __inline_isnanf(float __x) {
// hehe, note, in C the result of != has type **int**
return __x != __x;
}
) and then somebody “modernized” the code by just prepending std:: and changing <math.h> to <cmath>.
Saying that - if you look at how this IsNan used, you’ll find cases there the type is, indeed, important - calling Max(isNan(), somethingElseNotBool) for example.
HI,
I think historically TMath::IsNaN was returning an int following the C insan implementation that returns an integer.
I agree we should change to Bool_t. It is not a backward-incompatible change, but it is clear in same cases users might get a compiler error, like when using it in template functions