0

I have the following float value that is being converted to double

float fVal = 0.0f;
double dVal = static_cast<double>(fVal);

I want to control the number of decimal places that dVal gets. I found std::setprecision. But, all examples demostrate its usage in std::couts.

How can apply std::setprecision here to get 2 or 3 decimal places of precision ?

TheWaterProgrammer
  • 7,055
  • 12
  • 70
  • 159

0 Answers0