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

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -