Пример #1
0
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
}
Пример #2
0
/*********************  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() );
}
Пример #3
0
/*********************  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() );
}
Пример #4
0
/*********************  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() ; }