std::setprecision (3) - Linux Manuals
std::setprecision: std::setprecision
NAME
std::setprecision - std::setprecision
Synopsis
Defined in header <iomanip>
/*unspecified*/ setprecision( int n );
When used in an expression out << setprecision(n) or in >> setprecision(n), sets the precision parameter of the stream out or in to exactly n.
Parameters
n - new value for precision
Return value
Returns an object of unspecified type such that if str is the name of an output stream of type std::basic_ostream<CharT, Traits> or an input stream of type std::basic_istream<CharT, Traits>, then the expression str << setprecision(n) or str >> setprecision(n) behaves as if the following code was executed:
str.precision(n);
Example
// Run this code
Output:
See also
fixed
scientific
hexfloat
defaultfloat changes formatting used for floating-point I/O
(C++11)
(C++11)
precision (public member function of std::ios_base)