开发者

Doubt about strictfp and StrictMath

开发者 https://www.devze.com 2023-03-22 07:04 出处:网络
I have a little technical question, is it the same to call: public static strictfp double myMethod(double phi){

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 ...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号