...Thank you for that. What he is really looking for, for me, is a C/C++ solution to rounding floating point numbers(doubles) to a specific number of decimal places with the most accuracy that can be had...
Ray,
Fast Rounding of Floating Point Numbers in C/C++ on Wintel Platform
-
http://ldesoras.free.fr/doc/articles/rounding_en.pdf -
and ROUND 4 C++ example ex
http://cis.stvincent.edu/swd/basic/arithmetic.htmlquote
/* Given: Value a floating point number
NumPlaces a positive integer giving the number of
decimal places to which to round the answer.
Task: To round Value to NumPlaces decimal places. If NumPlaces
is not postive, Value is returned unchanged as the answer.
Return: The rounded number in the function name.
*/
float Round4(float Value, int NumPlaces)
{
int k, Temp;
float Factor;
Factor = 1;
for (k = 0; k < NumPlaces; k++)
Factor = Factor * 10;
Temp = Value * Factor + 0.5;
return Temp / Factor;
}
unquote
Hope, it helps.
- M.