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

BigDecimal.setScale(int, int) no longer throws ArithmeticException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 5.0
    • core-libs

      FULL PRODUCT VERSION :
      java version "1.5.0_07"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-b03)
      Java HotSpot(TM) Client VM (build 1.5.0_07-b03, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Fedora Core 5

      A DESCRIPTION OF THE PROBLEM :
      In 1.5, BigDecimal.setScale(int, int) no longer throws ArithmeticException if the scale parameter is smaller then zero.

      It should do so according to the spec, and does so in 1.4.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Testcase given.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      An ArithmeticException should be thrown. (Or the spec changed)
      ACTUAL -
      Returned the results of a division with 10^-scale.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      (new BigDecimal(1.0)).setScale(-10, BigDecimal.ROUND_DOWN);

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Check the parameters yourself before calling setScale.

            darcy Joe Darcy
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: