C Standard Library

C <math.h> - isfinite()



The C <math.h> isfinite() macro returns true if the given argument is a finite value, else returns false. A finite value is any floating-point value that is neither infinity nor NaN (Not-A-Number).

Syntax

isfinite(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 isfinite() macro.

#include <stdio.h>
#include <math.h>
 
int main (){

  printf("isfinite(10.5): %d\n", isfinite(10.5));
  printf("isfinite(1.0/0.0): %d\n", isfinite(1.0/0.0));
  printf("isfinite(0.0/0.0): %d\n", isfinite(0.0/0.0));
  printf("isfinite(sqrt(-1.0)): %d\n", isfinite(sqrt(-1.0)));
  return 0;
}

The output of the above code will be:

isfinite(10.5): 1
isfinite(1.0/0.0): 0
isfinite(0.0/0.0): 0
isfinite(sqrt(-1.0)): 0

❮ C <math.h> Library