Question

If in C++ I got the any of the following values, how to verify or compare them?

float pinf = std::numeric_limits<float>::infinity();
double dpinf = std::numeric_limits<double>::infinity();

float ninf = -std::numeric_limits<float>::infinity();
float NaN = std::numeric_limits<float>::quiet_NaN();
float nNaN = -std::numeric_limits<float>::quiet_NaN();
double dNaN = std::numeric_limits<double>::quiet_NaN();
Était-ce utile?

La solution

You can use std::fpclassify or any of the related functions.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top