简体   繁体   English

Double.parseDouble-在diff平台上对相同结果是否有严格的实现?

[英]Double.parseDouble - any strict implementation for same results on diff platforms?

I need some floating point operations to produce the same exact results between different machines. 我需要一些浮点运算才能在不同的机器之间产生相同的精确结果。 I see we have things like strictfp and StrictMath to do this. 我看到我们可以使用strictfp和StrictMath之类的工具来执行此操作。 My starting state however will load the floating point numbers from a String. 但是,我的起始状态将从字符串加载浮点数。 Example: 例:

double x = Double.parseDouble("0.1234..");

I don't see something like StrictMath.parseDouble() though. 我没有看到类似StrictMath.parseDouble()的东西。 Is there something like that? 有那样的东西吗?

My app has to save the state of the operations to disk at arbitrary points and reload state, I'm not even sure parseDouble will restore values to their exact representations on the same machine. 我的应用程序必须将操作状态保存到磁盘上的任意位置并重新加载状态,我什至不确定parseDouble是否会将值还原到同一台计算机上的精确表示形式。

I believe I might have to use a fixed point math approach for this, but wanted to check if I'm missing anything here. 我相信我可能必须为此使用定点数学方法,但想检查我是否在这里缺少任何内容。

Thanks 谢谢

I need some floating point operations to produce the same exact results between different machines. 我需要一些浮点运算才能在不同的机器之间产生相同的精确结果。

This is what Double.parseDouble does. 这就是Double.parseDouble所做的。 From the Javadoc from Double.valueOf 来自Double.valueOf的Javadoc

Returns a Double object holding the double value represented by the argument string s. 返回一个Double对象,该对象包含参数字符串s表示的double值。

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

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