Hi :o)
I've a value : 3.5463729
But I want to keep only the value : 3.55
Is there a function to round decimals
Thanks !
Duke :-)
Printable View
Hi :o)
I've a value : 3.5463729
But I want to keep only the value : 3.55
Is there a function to round decimals
Thanks !
Duke :-)
try this
float f = 3.5463729;
f *= 100.0f;
int i = (int)f;//truncate
f = ((float)i) / 100.0f;
//or combine to save typing
f = ((float)((int)(f * 100))) /100.0f;
not tested but it should work. The idea is to move the decimal right 2, truncate, the move the decimal back