Skip to main content

Command Palette

Search for a command to run...

Setprecision Manipulator Fixed and Scientific

Published
1 min read
B

Hi, I'm a student developer. Knew front end web development. Learning Azure.

The setprecision Manipulator is used with floating point numbers. It is used to set the number of digits printed to the right of the decimal point. This may be used in two forms: fixed and scientific These two forms are used when the keywords fixed or scientific are appropriately used before the setprecision manipulator. The keyword fixed before the setprecision manipulator prints the floating point number in fixed notation. The keyword scientific, before the setprecision manipulator, prints the floating point number in scientific notation.

using namespace std;
int main(){
    cout.precision(3);
    double n;
    cin>>n;
    cout<<fixed<<n<<endl;
    cout<<scientific<<n;
    return 0;
}