【问题标题】:Doubt about strictfp and StrictMath对 strictfp 和 StrictMath 的怀疑
【发布时间】:2023-05-12 17:55:02
【问题描述】:

我有一点技术问题,打电话是一样的吗:

   public static strictfp double myMethod(double phi){
       return Math.exp(phi);
   }

或:

   public static double myMethod(double phi){
       return StrictMath.exp(phi);
   }

或者strictfp 关键字是否只适用于方法内部使用的基本算术运算+ - * /

【问题讨论】:

    标签: java math floating-point strictfp


    【解决方案1】:

    或者strictfp关键字只适用于方法内部使用的基本算术运算+ - * /?

    strictfp 关键字仅适用于它所修改的方法或类中的操作。它不会将对Math 函数的调用重新路由到StrictMath,因此您需要显式使用StrictMath 而不是Math

    来自http://www.esus.com/javaindex/j2se/jdk1.2/javamath/strictfp.html

    如果 浮点表达式strictfp “范围” 内,则结果将与 IEEE 754 中描述的一样可预测 ...

    【讨论】:

      最近更新 更多