Java BigInteger clearBit() Method

The clearBit() method of Java BigInteger classreturns a BigInteger which corresponds to the result of clearing a bit designated by the method argument n.

Syntax:

Parameter:

n-index of bit to clear entered by user

Returns:

This method returns a bigInteger of value,(this &~(1<<n)).

Throws:

ArithmeticException - if n is negative.

Example 1

Test it Now

Output:

Result of  clearBit operation on 15  is  11

Example 2

Test it Now

Output:

java.lang.ArithmeticException: Neagtive bit address

Next TopicJava BigInteger




Latest Courses