Hej
Its too simple looking but I need c++ code to round off any floating point number to the nearest 1000th. I read somewhere to do it like this:
double number = cos(theta);
double rounded_1000th = floor((x*1000.0 + 0.5)/1000.0);
But this solution fails for numbers less than zero e.g., it rounds 0.70712 to 0.0 instead of 0.707
Can anyone help?