iPhone NSNumberFormatter 用于小于 1 的值
我有一个浮点值
i.e. 0.0467
想要一个字符串 05
怎么才能得到呢?不包括小数点 (.)。
更准确地说,如果我有一个浮点数,我想将其分为整数和小数,最好分为两个字符串部分。
I have a floating point value
i.e. 0.0467
Want have a string05
how can get it? Excluding the decimal point (.).
More precisely, if I have a floating point number, I want to divide it to integral and decimal, preferably into two string parts.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
按照此操作,您将获得想要的结果。
By following this, you will get desired result.
您正在寻找的设置称为分数:
您可以选择使用
-[NSNumberFormatter setRoundingMode:]
来指定应如何进行舍入。The setting you are looking for is called fraction digits:
Optionally you can use
-[NSNumberFormatter setRoundingMode:]
to specify how rounding should be done.