Questions tagged «double-precision»

12
在小数点后如何将Dart中的double舍入到给定的精度?
给定一个double,我想将其四舍五入到小数点后的给定精度点,类似于PHP的round()函数。 我在Dart文档中可以找到的最接近的东西是double.toStringAsPrecision(),但这不是我所需要的,因为它包括精度总点中小数点前的数字。 例如,使用toStringAsPrecision(3): 0.123456789 rounds to 0.123 9.123456789 rounds to 9.12 98.123456789 rounds to 98.1 987.123456789 rounds to 987 9876.123456789 rounds to 9.88e+3 随着数量的增加,我相应地失去了小数点后的精度。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.