• 特殊浮点值 Java


     

    // Finite +-0.0
    System.out.println("Finite with +-0.0:");
    System.out.println("Finite / +-0.0: " + 8.0 / 0.0);
    System.out.println("Finite / +-0.0: " + 8.0 / -0.0);
    System.out.println("Finite * +-0.0: " + 8.0 * 0.0);
    System.out.println("Finite * +-0.0: " + 8.0 * -0.0);
    System.out.println("Finite % +-0.0: " + 8.0 % 0.0);
    System.out.println("Finite % +-0.0: " + 8.0 % -0.0);
    System.out.println("Finite + +-0.0: " + 8.0 + 0.0);
    System.out.println("Finite + +-0.0: " + 8.0 + -0.0);
    System.out.println("Finite - +-0.0: " + (8.0 - 0.0));
    System.out.println("Finite - +-0.0: " + (8.0 - -0.0));
    System.out.println();

    Finite with +-0.0:
    Finite / +-0.0: Infinity
    Finite / +-0.0: -Infinity
    Finite * +-0.0: 0.0
    Finite * +-0.0: -0.0
    Finite % +-0.0: NaN
    Finite % +-0.0: NaN
    Finite + +-0.0: 8.00.0
    Finite + +-0.0: 8.0-0.0
    Finite - +-0.0: 8.0
    Finite - +-0.0: 8.0


    // Finite +-∞
    System.out.println("Finite with +-∞:");
    System.out.println(8.0 / (1.0 / 0));
    System.out.println(8.0 / (-1.0 / 0));
    System.out.println(8.0 * (1.0 / 0));
    System.out.println(8.0 * (-1.0 / 0));
    System.out.println(8.0 % (1.0 / 0));
    System.out.println(8.0 % (-1.0 / 0));
    System.out.println(8.0 + (1.0 / 0));
    System.out.println(8.0 + (-1.0 / 0));
    System.out.println(8.0 - (1.0 / 0));
    System.out.println(8.0 - (-1.0 / 0));
    System.out.println();

    Finite with +-∞:
    0.0
    -0.0
    Infinity
    -Infinity
    8.0
    8.0
    Infinity
    -Infinity
    -Infinity
    Infinity


    // +-0.0 +-0.0
    System.out.println("+-0.0 with +-0.0:");
    System.out.println(0.0 / 0.0);
    System.out.println(0.0 / -0.0);
    System.out.println(0.0 * 0.0);
    System.out.println(0.0 * -0.0);
    System.out.println(0.0 % 0.0);
    System.out.println(0.0 % -0.0);
    System.out.println(0.0 + 0.0);
    System.out.println(0.0 + -0.0);
    System.out.println(0.0 - 0.0);
    System.out.println(0.0 - -0.0);
    System.out.println();

    System.out.println(-0.0 / 0.0);
    System.out.println(-0.0 / -0.0);
    System.out.println(-0.0 * 0.0);
    System.out.println(-0.0 * -0.0);
    System.out.println(-0.0 % 0.0);
    System.out.println(-0.0 % -0.0);
    System.out.println(-0.0 + 0.0);
    System.out.println(-0.0 + -0.0);
    System.out.println(-0.0 - 0.0);
    System.out.println(-0.0 - -0.0);
    System.out.println();

    +-0.0 with +-0.0:
    NaN
    NaN
    0.0
    -0.0
    NaN
    NaN
    0.0
    0.0
    0.0
    0.0

    NaN
    NaN
    -0.0
    0.0
    NaN
    NaN
    0.0
    -0.0
    -0.0
    0.0


    // +-∞ Finite
    System.out.println("+-∞ with Finite:");
    System.out.println((1.0 / 0) / 8.0);
    System.out.println((-1.0 / 0) / 8.0);
    System.out.println((1.0 / 0) * 8.0);
    System.out.println((-1.0 / 0) * 8.0);
    System.out.println((1.0 / 0) % 8.0);
    System.out.println((-1.0 / 0) % 8.0);
    System.out.println((1.0 / 0) + 8.0);
    System.out.println((-1.0 / 0) + 8.0);
    System.out.println((1.0 / 0) - 8.0);
    System.out.println((-1.0 / 0) - 8.0);
    System.out.println();

    +-∞ with Finite:
    Infinity
    -Infinity
    Infinity
    -Infinity
    NaN
    NaN
    Infinity
    -Infinity
    Infinity
    -Infinity


    // +-∞ +-∞
    System.out.println("+-∞ with +-∞:");
    System.out.println((1.0 / 0) / (1.0 / 0));
    System.out.println((-1.0 / 0) / (-1.0 / 0));
    System.out.println((1.0 / 0) * (1.0 / 0));
    System.out.println((-1.0 / 0) * (-1.0 / 0));
    System.out.println((1.0 / 0) % (1.0 / 0));
    System.out.println((-1.0 / 0) % (-1.0 / 0));
    System.out.println((1.0 / 0) + (1.0 / 0));
    System.out.println((-1.0 / 0) + (-1.0 / 0));
    System.out.println((1.0 / 0) - (1.0 / 0));
    System.out.println((-1.0 / 0) - (-1.0 / 0));
    System.out.println();

    System.out.println((1.0 / 0) / (-1.0 / 0));
    System.out.println((-1.0 / 0) / (1.0 / 0));
    System.out.println((1.0 / 0) * (-1.0 / 0));
    System.out.println((-1.0 / 0) * (1.0 / 0));
    System.out.println((1.0 / 0) % (-1.0 / 0));
    System.out.println((-1.0 / 0) % (1.0 / 0));
    System.out.println((1.0 / 0) + (-1.0 / 0));
    System.out.println((-1.0 / 0) + (1.0 / 0));
    System.out.println((1.0 / 0) - (-1.0 / 0));
    System.out.println((-1.0 / 0) - (1.0 / 0));
    System.out.println();

    +-∞ with +-∞:
    NaN
    NaN
    Infinity
    Infinity
    NaN
    NaN
    Infinity
    -Infinity
    NaN
    NaN

    NaN
    NaN
    -Infinity
    -Infinity
    NaN
    NaN
    NaN
    NaN
    Infinity
    -Infinity

     

    // +-0 +-∞
    System.out.println("+-0 with +-∞:");
    System.out.println(0.0 / (1.0 / 0));
    System.out.println(0.0 / (-1.0 / 0));
    System.out.println(0.0 * (1.0 / 0));
    System.out.println(0.0 * (-1.0 / 0));
    System.out.println(0.0 % (1.0 / 0));
    System.out.println(0.0 % (-1.0 / 0));
    System.out.println(0.0 + (1.0 / 0));
    System.out.println(0.0 + (-1.0 / 0));
    System.out.println(0.0 - (1.0 / 0));
    System.out.println(0.0 - (-1.0 / 0));
    System.out.println();

    System.out.println(-0.0 / (1.0 / 0));
    System.out.println(-0.0 / (-1.0 / 0));
    System.out.println(-0.0 * (1.0 / 0));
    System.out.println(-0.0 * (-1.0 / 0));
    System.out.println(-0.0 % (1.0 / 0));
    System.out.println(-0.0 % (-1.0 / 0));
    System.out.println(-0.0 + (1.0 / 0));
    System.out.println(-0.0 + (-1.0 / 0));
    System.out.println(-0.0 - (1.0 / 0));
    System.out.println(-0.0 - (-1.0 / 0));
    System.out.println();

    +-0 with +-∞:
    0.0
    -0.0
    NaN
    NaN
    0.0
    0.0
    Infinity
    -Infinity
    -Infinity
    Infinity

    -0.0
    0.0
    NaN
    NaN
    -0.0
    -0.0
    Infinity
    -Infinity
    -Infinity
    Infinity

  • 相关阅读:
    Math app 2.0
    “口袋精灵”单元测试
    学习进度条
    本学期总结
    sprint2的总结及团队贡献分
    点餐系统Sprint1总结
    实验8
    实验7
    实验6
    实验五
  • 原文地址:https://www.cnblogs.com/diyishijian/p/5060251.html
Copyright © 2020-2023  润新知