c++ - Changing number precision -


How would you change the accuracy of a number for example: float n = 1.2345 and save it With this change in 'code' 1.23 go back to the variable 'N'?

  float n = 1.2345; Int scale = n * 100 n = static_cut & lt; Float & gt; (Scale) / 100.0;  

Or in a line:

  n = static_cast & lt; Float & gt; (Static_cast & lt; int & gt; (n * 100)) / 100;  

Comments