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

java.math.BigX should include add(Number)

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P5 P5
    • None
    • 1.4.0
    • core-libs
    • x86
    • windows_2000



      Name: jl125535 Date: 04/23/2002


      FULL PRODUCT VERSION :
      $ java -version
      java version "1.4.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
      Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

      FULL OPERATING SYSTEM VERSION :
      Win2k

      A DESCRIPTION OF THE PROBLEM :
      java.math.BigX contains methods of the form "BigInteger
      add(BigInteger)". They should be of the form "Number
      add(Number)" allowing BigDecimals and BigIntegers to play
      nicely together. This will require a redesign.

      This bug can be reproduced occasionally.

      CUSTOMER WORKAROUND :
      if (lvalue instanceof BigInteger) {
          if (rvalue instanceof BigInteger) {
              lvalue =
      ((BigInteger)lvalue).add((BigInteger)rvalue);
          } else {
              lvalue = (new
      BigDecimal(lvalue)).add((BigDecimal)rvalue);
          }
      } else {
          if (rvalue instanceof BigInteger) {
              lvalue = ((BigDecimal)lvalue)
                  .add(new BigDecimal((BigInteger)rvalue));
          } else {
              lvalue =
      ((BigDecimal)lvalue).add((BigDecimal)rvalue);
          }
      }
      (Review ID: 145732)
      ======================================================================

            darcy Joe Darcy
            jleesunw Jon Lee (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: