Returns whether x is a finite value.
The C99 prototype is listed as follows.
macro isfinite(x)
The C++11 prototype is listed as follows.
bool isfinite (float x); bool isfinite (double x); bool isfinite (long double x);
This function has the following parameter.
A non-zero value ( true) if x is finite; and zero ( false) otherwise.
#include <stdio.h> /* printf */
#include <math.h> /* isfinite, sqrt */
//from ww w . jav a2 s . co m
int main()
{
printf ("isfinite(0.0) : %d\n",isfinite(0.0));
printf ("isfinite(sqrt(-1.0)): %d\n",isfinite(sqrt(-1.0)));
return 0;
}
The code above generates the following result.
#include <stdio.h>
#include <math.h>
#include <float.h>
//from w w w . j ava 2 s . co m
int main(void)
{
printf("isfinite(NAN) = %d\n", isfinite(NAN));
printf("isfinite(INFINITY) = %d\n", isfinite(INFINITY));
printf("isfinite(0.0) = %d\n", isfinite(0.0));
printf("isfinite(DBL_MIN/2.0) = %d\n", isfinite(DBL_MIN/2.0));
printf("isfinite(1.0) = %d\n", isfinite(1.0));
printf("isfinite(exp(800)) = %d\n", isfinite(exp(800)));
}
The code above generates the following result.