Release Note: Correct Scale Handling of BigDecimal.sqrt

XMLWordPrintable

    • Type: Sub-task
    • Resolution: Unresolved
    • Priority: P4
    • 26
    • Affects Version/s: 26
    • Component/s: core-libs

      Due to an oversight when `BigDecimal.sqrt` was first added to the platform, its preferred scale was defined as floor(argumentScale / 2.0) rather than ceil(argumentScale / 2.0). For many argumentScale's these expression are equivalent, but for odd and positive scales they differ by 1. The latter definition aligns with the analagous concept for decimal floating-point types specified by the IEEE 754 floating-point standard and Java SE 26 is changed to use this latter definition.

      Before and after this change, numerically equal results will be returned; that is `oldResult.compareTo(newResult) == 0`. If the results differ, they will _only_ differ in their representation (for example `10` vs `1e1`).
      In more detail, if the scale of the argument is even, the preferred scale is the same before and after this change. If the scale of the argument is odd and _negative_, the preferred scale is the same before and after this change.
      Additionally, the result may still be the same even when the scale of argument is odd and _positive_ since the scale is only _preferred_ and the scale of the result is also a function of other factors, including the precision being used for the computation.

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

              Created:
              Updated: