Hey guys,
I was wondering how i could round a floating point number. I know how to do it with the print function but i need to do it in a calculation:
for example I would like the number 0.009999 to say .01
thanks
Printable View
Hey guys,
I was wondering how i could round a floating point number. I know how to do it with the print function but i need to do it in a calculation:
for example I would like the number 0.009999 to say .01
thanks
This should work, I didn't test it though.
-PreludeCode:double round ( double value, unsigned decimal )
{
return ceil ( value * pow ( 10.0, decimal ) + .5 ) / pow ( 10.0, decimal );
}