如果不使用 strictfp,代码是否会以某种方式变得不兼容?

Does code becomes non - compliant in someway if strictfp not used?

我们即将进行第一次代码审核,有人告诉我不使用 strictfp 进行浮点运算可能会标记我们。软件在 Windows 机器上编码并部署到 Solaris 机器以供生产使用。关于它是真的有什么建议吗?

此外,如果不使用“strictfp”会使浮点运算代码不兼容或不可移植,为什么仍然允许以 非 strictfp 方式进行计算?

CERT Secure Coding Standards, NUM53-J 让我觉得必须使用 strictfp:

Programs that require consistent results from floating-point operations across different JVMs and platforms must use the strictfp modifier.

如果您的应用程序需要浮点运算在不同的 JVM 之间保持一致,那么是的,您需要 strictfp。如果它没有,那么不,你没有。某些应用程序不需要一致性,并且可以从不使用 strictfp 的中间计算步骤中获得更高精确度的潜力中获益。其他人需要为相同的输入提供完全相同的输出,因此需要 strictfp 来保证输出的可移植性。