<math.h>
头文件里。isfinite(x)
#include <stdio.h> #include <math.h> int main() { double numbers[] = {3.14, INFINITY, -INFINITY, NAN, 0.0}; for(int i = 0; i < 5; i++) { if (isfinite(numbers[i])) { printf("%.3f is finite.\n", numbers[i]); } else { printf("%.3f is not finite.\n", numbers[i]); } } return 0; }输出结果为:
3.140 is finite.
inf is not finite.
-inf is not finite.
nan is not finite.
0.000 is finite.
本文链接:http://task.lmcjl.com/news/13972.html