inline MyFloat ceil ( MyFloat const& x ) { #if !defined(BOOST_NO_STDC_NAMESPACE) return MyFloat ( std::ceil(x.to_builtin()) ) ; #else return MyFloat ( ::ceil(x.to_builtin()) ) ; #endif }
/********************* TestDigits ************************************* Allows testing of the member functions Digits and MaxDigits. This routine assumes that input and output functions for MyFloats have been written and debugged. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ void TestDigits() { MyFloat X; cout <<"\n============ Testing Digits and MaxDigits ==============\n\n"; cout << "X.MaxDigits() = " << X.MaxDigits() << " \n\n"; do { cout << "\nEnter MyFloat ==> "; cin >> X; cin.ignore(1000, '\n'); // Discard all chars in input stream. cout << "\nDigits(" << X << ") = " << X.Digits() << endl; } while ( SpaceBarToContinue() ); }
/********************* TestRead *************************************** Allows testing of the member function Read of MyFloat. The Write function is assumed to be correct! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ void TestRead() { MyFloat X; cout << "\n>>>>>>>> Testing Read function >>>>>>>>>>>>\n"; do { cout << "\nEnter a MyFloat ==> "; cin >> X; cin.ignore(1000, '\n'); // Discard all chars in input stream. if ( X.Digits() == 0 ) // No significant digits cout << "\nInput error! "; cout << "\nAfter read, X = '"<< X << "'\n"; } while ( SpaceBarToContinue() ); }
/********************* TestAssignment ********************************* Allows testing of the member functions "=" of MyFloat. This routine assumes that input and output functions for MyFloats have been written and debugged. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ void TestAssignment() { MyFloat X; char X_Str[100]; cout << "\n------------ Testing \"=\" for MyFloat --------------------\n"; do { cout << "\nEnter string holding float: "; cin.getline(X_Str, 100); X = X_Str; // Call MyFloat = operator if ( X.Digits() == 0 ) // Error in string format cout << "\nFormat error! "; cout << "\nAfter assignment, 'X = "<< X << "'" << endl; } while ( SpaceBarToContinue() ); }
static double apply ( MyFloat const& n ) { return n.to_builtin() ; }