// float.cpp:   Format real numbers
#include <iostream.h>

main()
{
    float x = 12345.6789, y = 12345;
    
    cout << x << ' ' << y << '\n';
    
    // Show two decimals
    cout.precision(2);
    cout << x << ' ' << y << '\n';
    
    // Show trailing zeroes
    cout.setf(ios::showpoint);
    cout << x << ' ' << y << '\n';
    
    // Show sign
    cout.setf(ios::showpos);
    cout << x << ' ' << y << '\n';

    // Return sign and precision to defaults
    cout.unsetf(ios::showpos);
    cout.precision(0);
    
    // Use scientific notation
    cout.setf(ios::scientific,ios::floatfield);
    float z = 1234567890.123456;
    cout << z << '\n';
    cout.setf(ios::uppercase);
    cout << z << '\n';
    return 0;
}

// Output
// 12345.678711 12345
// 12345.68 12345
// 12345.68 12345.00
// +12345.68 +12345.00
// 1.234568e+09
// 1.234568E+09

