December 2005
Beginner to intermediate
618 pages
20h 19m
English
isfinite
Tests whether a given floating-point value is a finite number
#include <math.h> intisfinite( floatx); intisfinite( doublex); intisfinite( long doublex);
The macro isfinite() yields
a nonzero value (that is, true)
if its argument is not an infinite number and not a NaN. Otherwise,
isfinite() 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.
double vsum( int n, ... )
// n is the number of arguments in the list
{
va_list argptr;
double sum = 0.0, next = 0.0;
va_start( argptr, n );
while ( n− )
{
next = va_arg( argptr, double );
sum += next;
if (isfinite( sum ) == 0 )
break; // If sum reaches infinity, stop adding.
}
va_end( argptr );
return sum;
}Read now
Unlock full access