I have a double value as 22.368511 I want to round it to 2 decimal places. i.e. it should return 22.37
How can I do that?
You could do this:
NSNumberFormatter* f = [[NSNumberFormatter alloc] init]; [f setNumberStyle:NSNumberFormatterDecimalStyle]; [f setFormat:@0.00"]; // test NSNumber* a = @12; NSString* s = [f stringFromNumber:a]; NSLog(@"%@", s);