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

BigInteger returns an int for bitLength()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 6u39
    • core-libs
    • None

      FULL PRODUCT VERSION :
      1.6.0_39 (although the bug still exists in version 7)

      ADDITIONAL OS VERSION INFORMATION :
      Any standard desktop system

      A DESCRIPTION OF THE PROBLEM :
      BigInteger.bitLength() returns an int, despite the fact that a BigInteger can hold >= 2^31 bits.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      BigInteger bi = BigInteger.TEN.pow(600000000).pow(2);

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      the returned value will be negative
      ACTUAL -
      I haven't tried it

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      See above
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Document the method as SILENTLY returning an invalid value if the BigInteger contains >= 2^31 bits.

            darcy Joe Darcy
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: