U++ Forum - RDF feed
https://www.ultimatepp.org/forums/
rounding to decimals implementation
https://www.ultimatepp.org/forums/index.php?t=rview&goto=44429&th=9231#msg_44429
Hi all,
I have not found that in the library.
Here is the implementation.
double roundd ( double n, int decimals )
{
double p = ipow10 ( decimals );
return floor ( n*p + 0.5 ) / p;
}
A.]]>aftershock2015-03-11T10:24:53-00:00Re: rounding to decimals implementation
https://www.ultimatepp.org/forums/index.php?t=rview&goto=44430&th=9231#msg_44430
aftershock wrote on Wed, 11 March 2015 11:24
I have not found that in the library.
Here is the implementation.
double roundd ( double n, int decimals )
{
double p = ipow10 ( decimals );
return floor ( n*p + 0.5 ) / p;
}
Hi Aftershock,
It is not in the library, but you exactly reinvented what is written in documentation See About rounding double values.
Best regards,
Honza ]]>dolik.rce2015-03-11T10:43:20-00:00