开发者

NSString scanning?

i am having NSString* str = @"1223.2212311"; i want to convert it 开发者_JAVA技巧as 1223.22(after floating point two chars),is it possible through NSString?i have to use NSScanner? any help please?


How about something like:

NSString* str = @"1223.2212311";
NSString* result = [NSString stringWithFormat:@"%.2f", [str floatValue]];


You should take a look at NSNumberFormatter.


If the strings aren't going to be localized, you can just use -[NSString floatValue] to parse them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜