Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 15
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b18

      Description

      The Math functions abs(int) and abs(long) return MIN_VALUE if MIN_VALUE is provided as input. This is correct and well-defined behavior, but it's counterintuitive, as many people expect the result of abs() always to be positive.

      The Math class includes functions named addExact(), subtractExact(), and multiplyExact() that throw exceptions if boundary cases with integral wraparound are encountered. Perhaps there should be similar functions for abs(), possibly named absExact(), that also throw exceptions for their (single) edge cases. There would need to be overloads for int and long.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                darcy Joe Darcy
                Reporter:
                smarks Stuart Marks
              • Votes:
                1 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: