C <math.h> - isinf()
The C <math.h> isinf() macro returns true if the given argument is an infinity value (either positive infinity or negative infinity), else returns false.
Syntax
isinf(x)
Parameters
x |
Specify a floating-point value. |
Return Value
Returns true (non-zero value) if the argument is an infinity value, else returns false (zero value).
Example:
The example below shows the usage of isinf() macro.
#include <stdio.h> #include <math.h> int main (){ printf("isinf(10.5): %d\n", isinf(10.5)); 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; }
The output of the above code will be:
isinf(10.5): 0 isinf(1.0/0.0): 1 isinf(-1.0/0.0): -1 isinf(sqrt(-1.0)): 0
❮ C <math.h> Library