December 2005
Beginner to intermediate
618 pages
20h 19m
English
isinf
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.
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;
}Read now
Unlock full access