cout << std::fixed << std::setprecision(3) << d << '\n';in c++ code example Example: set precision with fixed c++ int x = 109887; cout << fixed << setprecision(3) << x;