One, code.
-(void) viewdidload{ [Super Viewdidload]; Do any additional setup after loading the view. NSLog (@ "--float-%@-", [self stringdisposewithfloat:9.000899990000]); } #pragma-mark-functions//floating-point number to process and remove excess 0-(NSString *) Stringdisposewithfloat: (float) floatvalue{nsstring *str = [ NSString stringwithformat:@ "%f", Floatvalue]; Long len = str.length; for (int i = 0; i < len; i++) { if (![ Str hassuffix:@ "0"]) break ; else str = [str substringtoindex:[str length]-1]; } if ([Str hassuffix:@ "."]) Avoid being parsed into 2 like 2.0000. { //s.substring (0, len-i-1); return [str substringtoindex:[str length]-1]; } else { return str;} }
Two, output.
2015-10-16 09:53:45.765 floating point processing and removing redundant 0[1554:47555]--float-9.0009-2015-10-16 09:53:48.824 floating point number processing and removing redundant 0[1554:47619] Terminating since there is no system app.
"Code note" floating-point number processing and removing the extra 0