C++: Controlling the Decimal places to be shown

While dealing with some scientific calculations, I came across a problem that no of digits that were represented after the decimal were not as per the in-file(8 digits). It was only taking 4 digits after the decimal. I had gone through various forums and discovered <iomanip>.

IOMANIP is a header file that is being used to represent the number of decimal places to be used.

#include<iomanip>

void main()
{
        cout<<setiosflags(ios::fixed)<<setprecision(8);
        ......
        ......
        ......
}

Using the above code you can represent as many digits you want to represent after the decimal.

Comments

Popular posts from this blog

Enable the imap in support in xampp server