How do I set a fixed (specified) number of decimal place precision for float variable. I am writing a program with frequent irrational number, and I want a way by which the float variable will store all the variable value at a fixed decimal place value.
So for example
//speicify a mechanism to store all float variable to 3 decimal place.
float time1 = 1/3;
float time2 = 2/3;
cout << "The values are stored as " << time1 << " and " << time2;
The values are stored as 0.333 and 0.667
And when I say 0.333, I really mean 0.333 only, i.e. 0.33300000....