c++ - Fixed Decimal Precision -


this question has answer here:

i using

std::cout.precision(5); 

to set decimal precision of outputs. however, rather have output output 5 decimal places (right won't show 0's). how change code reflect this?

you looking std::fixed std::setprecision.

#include <iomanip> #include <iostream> double f =1.1; std::cout << std::fixed; std::cout << std::setprecision(5) << f << std::endl; 

stdout

1.10000 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -