Turn off scientific notation on float

后端 未结 2 441
星月不相逢
星月不相逢 2020-12-04 01:29

I\'m trying to display number in standard notation

for example:

float f = 1230000.76

turns out to be,

1.23e+006
         


        
2条回答
  •  情歌与酒
    2020-12-04 02:17

    there are two things found in iomanip that must be included....first is fixed and the second is setprecision

    you need to write:

    cout<< fixed;
    cout<< setprecision(2)<< f;

    fixed disables the scientific notation i.e. 1.23e+006.... and fixed is a sticky manipulator so u need to disable it if u want to revert back to scientific notation...

提交回复
热议问题