小编jvn*_*173的帖子

Java的strictfp修饰符是否可以通过函数调用来应用?

更准确地说,如果调用堆栈中存在带有strictfp修饰符的函数,则调用堆栈顶部的函数是否也将遵守strictfp说明符?

public class Main {

    // case 1: strictfp not present at top of call stack
    private static double bar1(double x) {
        return Math.sin(x);
    }

    strictfp private static double foo1(double x) {
        return bar1(x);
    }

    // case 2: strictfp present at top of call stack
    strictfp private static double bar2(double x) {
        return Math.sin(x);
    }

    strictfp private static double foo2(double x) {
        return bar2(x);
    }

    public static void main(String[] args) {
        double x = 10.0;
        System.out.println(foo1(x)); // -0.5440211108893698
        System.out.println(foo2(x)); // …
Run Code Online (Sandbox Code Playgroud)

java floating-point strictfp

5
推荐指数
1
解决办法
53
查看次数

标签 统计

floating-point ×1

java ×1

strictfp ×1