Re: Rounding double
Richard Heathfield wrote:
Using "int(value+ .5)" is the wrong way to round because it works
incorrectly with negative values.
The correct way is "std::floor(val ue+.5)".
Richard Heathfield wrote:
*value = (int)(*value * p + 0.5) / (double)p;
incorrectly with negative values.
The correct way is "std::floor(val ue+.5)".
Comment