How can I round a float value to 2 post decimal positions?

I know this is old post but just in case someone else is looking for a quick Two step option.

float old = -3.04299553323;  
float new = [[NSString stringWithFormat:@"%.2f",old]floatValue];

Result = -3.04

The @”%.2f” will round to two decimal places. If you want three decimal places put @”%.3f” and so on.

Hope this helps!

Leave a Comment