JDK-8011942 : BigInteger returns an int for bitLength()
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.math
  • Affected Version: 6u39
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2013-03-19
  • Updated: 2013-05-11
  • Resolved: 2013-04-10
Related Reports
Duplicate :  
Description
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.
Comments
Closing as duplicate of JDK-6910473.
10-04-2013