/****************************************************************************** Demonstrate use of "finite" to detect IEEE double precision Infinity and Not-a-Number Translation: g++ project04.demo.cpp ******************************************************************************/ using namespace std; #include #include #include void test( double ); int main() { cout << endl << setiosflags( ios::fixed ) << setprecision(8); test( 7.625 ); test( 0.0 ); test( INFINITY ); test( NAN ); } void test( double val ) { if (finite( val )) { cout << "Value is a finite number: " << val << endl << endl; } else { cout << "Value is Infinity or Not-A-Number: " << val << endl << endl; } return; }