开发者

How to convert NSDecimal to NSString with custom format

How can开发者_运维技巧 I show NSDecimal with custom format? Something like "%.2f" or "%.4f". NSDecimalString just throws away zeroes (e.g 4.10 becomes 4.1).


[NSString stringWithFormat:@"%.2f", [[NSDecimalNumber decimalNumberWithDecimal:myDecimal] doubleValue]]

Alternatively, look into NSNumberFormatter.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜