home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / CPP / LONGFI.ZIP / MAIN.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-07  |  2.1 KB  |  48 lines

  1. #include <iostream.h>
  2. #include <iomanip.h>
  3. #include <stdlib.h>
  4. #include "long_fix.h"
  5.  
  6. void main ( int argc, char *argv[] )
  7. {
  8.     if (argc != 3)
  9.     {
  10.         cout << "USAGE: long_fix [first_number] [second_number]\n";
  11.         exit(0);
  12.     }
  13.  
  14.     long_fixed first = atof(argv[1]);
  15.     long_fixed second = atof(argv[2]);
  16.  
  17.     if (second == 0)
  18.     {
  19.         cout << "**** ERROR **** the second number can not be zero!\n";
  20.         exit(0);
  21.     }
  22.  
  23.     cout << " -first = " << (-first) << "\n\n";
  24.     cout << " first + second = " << (first + second) << '\n';
  25.     cout << " first - second = " << (first - second) << '\n';
  26.     cout << " first * second = " << (first * second) << '\n';
  27.     cout << " first / second = " << (first / second) << "\n\n";
  28.     cout << " abs(first) = " << abs(first) << '\n';
  29.     cout << " round(first) = " << round(first) << '\n';
  30.     cout << " ceil(first) = " << ceil(first) << '\n';
  31.     cout << " floor(first) = " << floor(first) << "\n\n";
  32.     cout << " first << round(second) = " << (first << (int)round(second)) << '\n';
  33.     cout << " first >> round(second) = " << (first >> (int)round(second)) << "\n\n";
  34.     cout << " first <  second = " << ((first < second) ? "TRUE" : "FALSE") << '\n';
  35.     cout << " first <= second = " << ((first <= second) ? "TRUE" : "FALSE") << '\n';
  36.     cout << " first >  second = " << ((first > second) ? "TRUE" : "FALSE") << '\n';
  37.     cout << " first >= second = " << ((first >= second) ? "TRUE" : "FALSE") << '\n';
  38.     cout << " first == second = " << ((first == second) ? "TRUE" : "FALSE") << '\n';
  39.     cout << " first != second = " << ((first != second) ? "TRUE" : "FALSE") << "\n\n";
  40.     cout << " first += second = " << (first += second) << '\n';
  41.     cout << " first -= second = " << (first -= second) << '\n';
  42.     cout << " first *= second = " << (first *= second) << '\n';
  43.     cout << " first /= second = " << (first /= second) << "\n\n";
  44.     cout << " first <<= round(second) = " << (first <<= (int)round(second)) << '\n';
  45.     cout << " first >>= round(second) = " << (first >>= (int)round(second)) << '\n';
  46. }
  47.  
  48.