Java.math.BigInteger Class Java.math.BigInteger.bitLength() Method - Java.math Package

What is Java math BigInteger bitLength() Method?

Description

The java.math.BigInteger.bitLength() returns the quantity of bits inside the minimum 's-complement representation of this BigInteger, except a signal bit. For fine BigIntegers, this is equal to the variety of bits inside the normal binary representation. It computes (ceil(log2(this < 0 ? -this : this+1))).

Declaration

Following is the declaration for java.math.BigInteger.bitLength() technique.

Parameters

NA

Return Value

This technique returns variety of bits in the minimum two's-complement representation of this BigInteger, with the exception of a sign bit.

Exception

NA

Example

the following instance suggests the usage of math.BigInteger.bitLength() technique.

Let us compile and run the above program, this will produce the following result −

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Java.math Package Topics