Hello, I would like to truncate the float to 4 digits. Are there some efficient way to do that? My current solution is:
double roundDBL(double d,unsigned int p=4)
{
unsigned int fac=pow(10,p);
double facinv=1.0/static_cast<double>(fac);
double x=static_cast<unsigned int>(d*fac)*facinv;
return x;
}
but using pow
and delete seems to me not so efficient.
kind regards
Arman.