iphone Programming Glossary: formattedstring
Convert to Float and Calculate http://stackoverflow.com/questions/14155360/convert-to-float-and-calculate i 1 c 1 withString @ 0. c Now we will convert all numbers in float NSString aString float aFloat NSMutableString formattedString NSMutableString alloc init NSScanner theScanner NSScanner scannerWithString formula while theScanner isAtEnd NO if theScanner.. NSScanner theScanner NSScanner scannerWithString formula while theScanner isAtEnd NO if theScanner scanFloat aFloat formattedString appendString NSString stringWithFormat @ f aFloat if theScanner scanUpToCharactersFromSet NSCharacterSet decimalDigitCharacterSet.. @ f aFloat if theScanner scanUpToCharactersFromSet NSCharacterSet decimalDigitCharacterSet intoString aString formattedString appendString aString return formattedString This will convert 2.222 .4 9999 7 0.7 .13 in to 2.222000 0.400000 9999.000000..
|