NSTimeInterval为可读的NSNumber

NSTimeInterval为可读的NSNumber

本文介绍了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.

推荐答案

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

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 03:29