For example:
double a = 2.12645; std::cout.precision(2); std::cout.setf(std::ios_base::fixed); std::cout << a;
It rounds and prints 2.13. How to make it so that it does not round off and display 2.12.
For example:
double a = 2.12645; std::cout.precision(2); std::cout.setf(std::ios_base::fixed); std::cout << a;
It rounds and prints 2.13. How to make it so that it does not round off and display 2.12.
If you need non-standard rounding (i.e. clipping), then there are two options - either immediately prepare a number for this (something like a = floor(a*100)/100;
or write your own formatter.
a > 0
? - alexlzSource: https://ru.stackoverflow.com/questions/163529/
All Articles