问题描述
我在java中实现了一些神经网络库,密集型的 double
(不是 Double>
)矩阵所以我来阅读关于 strictfp
关键字老实说我是读了关于 strictfp
的关键字。不明白它到底是什么,我正在寻找简单的解释,如果我应该使用它,为什么
strictfp表示浮点计算应该使用精确的IEEE754标准。如果没有strictfp,虚拟机可以自由地使用其他(但是是平台相关的)中间浮点数和双精度值的表示方式,以提高精度。
如果你需要使用strictfp在多个平台上完全相同的结果。避免它,如果你想你的当前平台可以给你最好的精度。在以下简单的添加:
2.0 + 1.1 + 3.0
您是否希望中间结果(例如2.0 + 1.1)被表示为IEEE754标准双精度,或者平台允许的最佳精度。 strictfp确保第一个,不使用strictfp允许虚拟机使用第二个选择。
不使用strictfp不会伤害性能,并且可能会本地浮点类型不映射到IEEE754的平台提高了性能,因为VM不需要在本机和IEEE754格式之间来回转换。答案是平台依赖,你需要测量。 I'm implementing some neural network library in java , and there are intensive So I came to read about strictfp indicates that floating point calculations should use the exact IEEE754 standard. Without strictfp, the VM is free to use other (but platform dependent) representations of intermediate float and double values, in order to increase precision. Use strictfp if you need the exact same results on multiple platforms. Avoid it if you want the best precision your current platform can give you. E.g. in the following simple addition: Do you want the intermediate results (e.g. 2.0 + 1.1) to be represented as an IEEE754 standard double, or with the best possible precision your platform allows. strictfp ensures the first, not using strictfp allows the VM to use the second alternative. Not using strictfp will not hurt performance, and may on platforms where the native float types don't map to IEEE754 increase performance, since the VM isn't required to convert back and forth in between native and IEEE754 formats. The answer is platform dependent, you'll need to measure. 这篇关于Java中的strictfp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!double
(not Double
) matrix operations, Matrices are large and performance is required of course.strictfp
keyword I honestly didn't understand what it does exactly and I was looking for simple explanation about If i should be using it or not and why 2.0 + 1.1 + 3.0