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
Post a Comment