Disable scientific float notation

I am trying to display a number in standard notation

eg:

float f = 1230000.76 

it turns out

 1.23e+006 
+7
source share
2 answers

in iomanip there are two things that should be included .... first fixed, and second - setprecision

you need to write:

soybe <<fixed;
soi <<setprecision (2) <<e;

fixed disables scientific notation, i.e. 1.23e + 006 .... and fixed is a sticky manipulator, so you need to disable it if you want to return to scientific notation ...

+6
source

Use -

 cout.setf(ios::fixed, ios::floatfield); cout.setf(ios::showpoint); 

before printing floating point numbers.

More information can be found here .

You can also set the output accuracy with the following statement -

 cout.precision(2); 

or just with -

 printf("%.2f", myfloat); 
+3
source

All Articles