Name
isinf
Synopsis
Tests whether a given floating point value is an infinity
#include <math.h> intisinf
( floatx
); intisinf
( doublex
); intisinf
( long doublex
);
The macro isinf()
yields a
nonzero value (that is, true
) if
its argument is a positive or negative infinity. Otherwise, isinf()
yields 0. The argument must be a
real floating-point type. The rule that floating-point types are
promoted to at least double
precision for mathematical calculations does not apply here; the
argument’s properties are determined based on its representation in
its actual semantic type.
Example
This function takes a short cut if it encounters an infinite addend:
double vsum( int n, va_list argptr )
{
double sum = 0.0, next = 0.0;
va_start( argptr, n );
for ( int i = 0; i < n; i ++ )
{
next = va_arg( argptr, double );
if (isinf
( next ) )
return next;
sum += next;
}
va_end( argptr );
return sum;
}
See Also
Get C in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.