Fed*_*era 3 java math floating-point strictfp
我有一点技术问题,打电话是一样的:
public static strictfp double myMethod(double phi){
return Math.exp(phi);
}
Run Code Online (Sandbox Code Playgroud)
要么:
public static double myMethod(double phi){
return StrictMath.exp(phi);
}
Run Code Online (Sandbox Code Playgroud)
或者strictfp关键字是否仅适用于+ - * /方法内使用的基本算术运算?
或者strictfp关键字是否仅适用于方法内部的基本算术运算+ - */?
该strictfp关键字仅适用于其修改的方法或类中的操作.它不会重新路由对Math函数的调用StrictMath,因此您需要显式使用StrictMath而不是Math.
来自http://www.esus.com/javaindex/j2se/jdk1.2/javamath/strictfp.html
如果浮点表达式在
strictfp"范围"内,则结果将如IEEE 754中所描述的那样可预测...