SyntaxFix
Write A Post
Hire A Developer
Questions
Simplify the accepted answer
Simplified example:
#include <iostream> #include <iomanip> int main() { double d = 122.345; std::cout << std::fixed << std::setprecision(2) << d; }
And you will get output
122.34
Reference:
std::fixed
std::setprecision