Digit limitation from decimal point in C++ -
I am new to C ++. I want to limit the double variable double A = 0.1239857 variable variable a with a decimal point two digits Therefore, a will be 0.12 . I know that C ++ has functions that give the largest or smallest integer which is more or less than the CL or the floor from a . Is there a function that applies the number of floating-point variables? Or how can I change the exact a variable?
The best regard is ...
Trying to, or just trying to change its displayed precision?
For pre (reducing additional points):
double scale = 0.01; // i.e. Round = (int / scale) * scale for the nearest one-handed value; or (as curved up / down, appropriate copy, jheriko's answer)
dual-scale = 0.01; // round = floor (value / scale + 0.5) * scale for the nearest one-handed value; For later:
Cust & lt; & Lt; Setcrison (2) & lt; & Lt; value; Where the parameter is setprecision () maximum number to display after a decimal point.
Comments
Post a Comment