ios - How to show two digits in float value -
I am using this code to show digits after the dot in the float value:
NSString * string = [NSString stringWithFormat: @ "% .2f", float value]; If float value works like 65.5234 and string = 65.52 but if float value is 65.5025, then it does not work and string = 65.5
I How can I change it? I need to show my string as 65.50 I am working with iOS 7
NSNumberFormatter * format = [[NSNumberFormatter alloc] init]; [Format set number number: NSNumberFormatterDecimalStyle]; [Format SetRounding Mode: NSNumberFormatterRoundHalfUp]; [Format SetmaxiumFrogress Detids: 2]; [Format SetiumFrogressDigit: 2]; String = [NSString stringWithFormat: @ "% @", [format stringFromNumber: [NSNumber Number explosion: 65.50055]];
Comments
Post a Comment