BigInteger.bitLength() has the following syntax.
public int bitLength()
In the following code shows how to use BigInteger.bitLength() method.
/*from w w w. j av a 2 s.co m*/ import java.math.BigInteger; public class Main { public static void main(String[] args) { BigInteger bi1 = new BigInteger("7"); BigInteger bi2 = new BigInteger("-7"); // perform bitlength operation on bi1, bi2 int i1 = bi1.bitLength(); int i2 = bi2.bitLength(); System.out.println(i1); System.out.println(i2); } }
The code above generates the following result.