You can set the accuracy of the output stream to whatever you want to get the desired results.
http://www.cplusplus.com/reference/ios/ios_base/precision/
, .
/ , , . , , , floatfield ( fixed scientific), ( default, fixed scientific).
, , , . , , , , . , , , . .
setprecision.
#include <iostream> // std::cout, std::ios
int main () {
double f = 3.14159;
std::cout.unsetf ( std::ios::floatfield );
std::cout.precision(5);
std::cout << f << '\n';
std::cout.precision(10);
std::cout << f << '\n';
std::cout.setf( std::ios::fixed, std:: ios::floatfield );
std::cout << f << '\n';
return 0;
}
:
3.1416
3.14159
3.1415900000
, 5 , - 6, , 10. , floatfield , , . 10 , floatfield .