isfinite - C math.h

C examples for math.h:isfinite

type

macro

From

<cmath>
<ctgmath>
<math.h>

Description

Returns whether x is a finite value.

A finite value is any floating-point value that is neither infinite nor NaN (Not-A-Number).

Prototype

bool isfinite (float x);
bool isfinite (double x);
bool isfinite (long double x);
     isfinite (x)

Parameters

Parameter Description
x A floating-point value.

Return value

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

Example

Demo Code


#include <stdio.h>
#include <math.h> /* isfinite, sqrt */

int main()//w  w  w.  j  a  v a2  s  . com
{
  int a = 0;
  printf("%d\n", isfinite(0.0));
  printf("%d\n", isfinite(1.0 / a));
  printf("%d\n", isfinite(-1.0 / a));
  printf("%d\n", isfinite(sqrt(-1.0)));
  return 0;
}

Related Tutorials