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

java.math.BigInteger misses the xxxValueExact methods

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 8
    • 6u10
    • core-libs
    • b08
    • x86
    • windows_vista
    • Verified

    Description

      FULL PRODUCT VERSION :
      java version "1.6.0_14"
      Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
      Java HotSpot(TM) Client VM (build 14.0-b16, mixed mode, sharing)


      A DESCRIPTION OF THE PROBLEM :
      Unlike java.math.BigDecimal, java.math.BigInteger misses the methods

       byteValueExact()
       shortValueExact()
       intValueExact()
       longValueExact()

      This makes it extremely difficult to implement efficient cast methods that are aware of integer overflows. Such cast are required, e.g. to implement other languages for the Java VM efficiently.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Look at the source code of java.lang.BigInteger. There are no xxxValueExact() methods. The xxxValue() methods do not throw an ArithmeticException in case of overflows.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Have dedicated methods that throw ArithmeticExceptions.
      ACTUAL -
      There are no dedicated methods that throw ArithmeticExceptions.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: