Online Java Compiler By
JavaTpoint.com
import java.math.BigInteger; public class BigIntegerBitLengthExample { public static void main(String[] args){ // create 2 BigInteger objects BigInteger big1,big2 ; // create 2 int objects int i1,i2 ; // assign values to big1, big2 big1= new BigInteger("8"); // 1000 big2 =new BigInteger("-9"); // 0110 //perform bitlength operation on big1, big2 i1 = big1.bitLength(); //total no of bitsafter excluding sign bit i2 = big2.bitLength(); //total no of bitsafter excluding sign bit String str1="Result of bitLength operation on "+ big1+" is "+ i1; String str2="Result of bitLength operation on "+ big2+" is "+ i2; System.out.println(str1); System.out.println(str2); } }
Output