Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8240632

Note differences between IEEE 754-2019 math lib special cases and java.lang.Math

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 17
    • 15
    • core-libs
    • b09

      For various math library functions, there are multiple plausible behaviors in some special cases. Starting with IEEE 754-2008 and continuing with IEEE 754-2019, the standard makes recommendations for handling those special values. In some of the special cases, the IEEE recommendations do not match the pre-existing behavior defined for java.lang.Math and java.lang.StrictMath. The java.lang.{Math, StrictMath} classes both long predate the floating-point standard to provide recommendations for the math library.

      These differences, and other notable ties to IEEE 754-2019 should be noted in the specification of java.lang.Math.

      The differences include:

      * cos(0.0) = 1.0
      * exp(0.0) = 1.0
      * acos(1.0) = 0.0
      * acos((+/- infinity) = pi/2
      * log(1.0) => 0.0
      * log10(1.0) => 0.0
      * hypot(+/-0, +/-0) => +0.0

      The Math/StrictMath implementations are expected to conform to most of these behaviors, but the current specification doesn't explicitly require them too.

            darcy Joe Darcy
            darcy Joe Darcy
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: