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

java.lang.Math class doc should be adjusted regarding -Exact methods

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: 14
    • Component/s: core-libs
    • Subcomponent:
    • Resolved In Build:
      b12

      Description

      The java.lang.Math class doc says,

       * In cases where the size is {@code int} or {@code long} and
       * overflow errors need to be detected, the methods {@code addExact},
       * {@code subtractExact}, {@code multiplyExact}, and {@code toIntExact}
       * throw an {@code ArithmeticException} when the results overflow.
       * For other arithmetic operations such as divide, absolute value,
       * increment by one, decrement by one, and negation, overflow occurs only with
       * a specific minimum or maximum value and should be checked against
       * the minimum or maximum as appropriate.

      There are methods decrementExact(), incrementExact(), and negateExact() that throw exceptions on overflow. These should be included in the list of operations that can detect overflow. The advice about checking specific values still applies to divide and absolute value operations, though.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jboes Julia Boes
              Reporter:
              smarks Stuart Marks
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: