NSTimeInterval为可读的NSNumber [英] NSTimeInterval to readable NSNumber

查看:434
本文介绍了NSTimeInterval为可读的NSNumber的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

NSTimeInterval == double; (例如169.12345666663)

NSTimeInterval == double; (e.g. 169.12345666663)

如何舍入此双精度值,以便在点后只剩两个数字?

如果结果是NSNumber,则非常好。

How can I round up this double so that there are only 2 digits left after the "dot"?
It would be very good if the result is a NSNumber.

推荐答案

如果这是为了显示目的,请查看 NSNumberFormatter

If this is for display purposes, take a look at NSNumberFormatter.

如果你真的想在计算中舍入双倍的某种原因,你可以使用标准的C round()函数。

If you really want to round the double in your calculations for some reason, you can use the standard C round() function.

这篇关于NSTimeInterval为可读的NSNumber的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆