Doubt about strictfp and StrictMath
I have a little technical question, is it the same to call:
public static strictfp double myMethod(double phi){
return Math.exp(phi);
}
or:
public static double myMethod(double phi){
return StrictMath.exp(phi);
}
Or does the 开发者_StackOverflowstrictfp
keyword just applies to the basic arithmetic operations + - * /
used inside the method?
Or does the strictfp keyword just applies to the basic arithmetic operations + - * / used inside the method?
The strictfp
keyword only applies to operations in the method or class it modifies. It doesn't reroute calls to Math
functions to StrictMath
, so you need to explicitly use StrictMath
instead of Math
.
From http://www.esus.com/javaindex/j2se/jdk1.2/javamath/strictfp.html
If a floating point expression is within a
strictfp
"scope", the results will be as predictable as described in IEEE 754 ...
精彩评论