floatnum.cpp 613 B

1234567891011121314151617181920
  1. // floatnum.cpp -- floating-point types
  2. #include <iostream>
  3. int main()
  4. {
  5. using namespace std;
  6. cout.setf(ios_base::fixed, ios_base::floatfield); // fixed-point
  7. float tub = 10.0 / 3.0; // good to about 6 places
  8. double mint = 10.0 / 3.0; // good to about 15 places
  9. const float million = 1.0e6;
  10. cout << "tub = " << tub;
  11. cout << ", a million tubs = " << million * tub;
  12. cout << ",\nand ten million tubs = ";
  13. cout << 10 * million * tub << endl;
  14. cout << "mint = " << mint << " and a million mints = ";
  15. cout << million * mint << endl;
  16. // cin.get();
  17. return 0;
  18. }