6.11.90 isinf Macro

Returns true if its argument is an infinity.

Include

<math.h>

Prototype

int isinf(floating-point x);

Argument

x
any floating-point number

Return Value

Returns true if x is either positive or negative infinity; zero otherwise.

Example

See the notes at the beginning of this chapter or section for information on using printf() or scanf() (and other functions reading and writing the stdin or stdout streams) in the example code.

#include <math.h>
#include <stdio.h>

int main(void)
{
  double x, y, z;

  x = 5.0;
  y = 0.0;
  z = x / y;
  if(isinf(z))
    printf("Infinity detected in division of %f by %f\n", x, y);
}

Example Output

Infinity detected in division of 5.000000 by 0.000000