macro/function
<cmath> <ctgmath>

isinf

macro
isinf(x)
function
bool isinf (float x);bool isinf (double x);bool isinf (long double x);
Is infinity
Returns whether x is an infinity value (either positive infinity or negative infinity).

In C, this is implemented as a macro that returns an int value. The type of x shall be float, double or long double.
In C++, it is implemented with function overloads for each floating-point type, each returning a bool value.

Parameters

x
A floating-point value.

Return value

A non-zero value (true) if x is an infinity; and zero (false) otherwise.

Example

1
2
3
4
5
6
7
8
9
10
11
12
/* isinf example */
#include <stdio.h>      /* printf */
#include <math.h>       /* isinf, sqrt */

int main()
{
  printf ("isinf(0.0)       : %d\n",isinf(0.0));
  printf ("isinf(1.0/0.0)   : %d\n",isinf(1.0/0.0));
  printf ("isinf(-1.0/0.0)  : %d\n",isinf(-1.0/0.0));
  printf ("isinf(sqrt(-1.0)): %d\n",isinf(sqrt(-1.0)));
  return 0;
}

Output:

isinf(0.0)      : 0
isinf(1.0/0.0)  : 1
isinf(-1.0/0.0) : 1
isinf(sqrt(-1.0): 0


See also