Possible Duplicate:
How can I round a float value to 2 post decimal positions?
Lets say I have a double number of 3.46. How do I round it to 3.50? I tried
NSLog(@"res: %.f", round(3.46));
but it return 3.
Do some calculations....
float f=3.46;
float num=f+0.05;//3.51
int intNum=num*10;//35
float floatNum=intNum/10.0;//3.5
NSLog(@"res: %.2f", floatNum); //3.50
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With