我用 float 进行一些计算,有时我将数字除以零,甚至零除以零。因此,我的输出数组的某些值包含 -1.#IND0000 值。之后我需要确定该值是“正常”还是“NaN”。我怎样才能用if语句做到这一点?
最佳答案
尝试isnan()
。这就是您要找的人。
#include <math.h>
void YourCode() {
float x = /* some value from your array here */;
if (isnan(x)) {
// ... do stuff ...
}
}
关于c++ - 确定NaN(不是数字值),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27388585/