C examples for math.h:isfinite
macro
<cmath> <ctgmath> <math.h>
Returns whether x is a finite value.
A finite value is any floating-point value that is neither infinite nor NaN (Not-A-Number).
bool isfinite (float x); bool isfinite (double x); bool isfinite (long double x); isfinite (x)
Parameter | Description |
---|---|
x | A floating-point value. |
A non-zero value (true) if x is finite; and zero ( false) otherwise.
#include <stdio.h> #include <math.h> /* isfinite, sqrt */ int main()//w w w. j a v a2 s . com { int a = 0; printf("%d\n", isfinite(0.0)); printf("%d\n", isfinite(1.0 / a)); printf("%d\n", isfinite(-1.0 / a)); printf("%d\n", isfinite(sqrt(-1.0))); return 0; }