简体   繁体   English

带时间的浮点精度-乘除法

[英]Floating point precision with Time - multiply vs divide

Will these statements execute with exactly the same results across different platforms? 这些语句在不同平台上执行的结果是否完全相同?

    currentTime = System . nanoTime ( ) * 0.000000001f ; // 01

    currentTime = System . nanoTime ( ) / 1000000000f ; // 02

The concern is loss of precision using a small floating point value. 使用小浮点值会导致精度下降。

Just leave it as a long. 只需将其保留很长时间。 No loss of precision and perfect Determinism across the board. 全面保持精度和完美的确定性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM