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