BigInteger clearBit() Method in Java Last Updated : 24 Jun, 2021 Comments Improve Suggest changes Like Article Like Report Prerequisite: BigInteger BasicsThe clearBit() method returns a BigInteger which is used to clear a particular bit position in a BigInteger. The bit at index n of binary representation of BigInteger will be cleared means converted to zero. Mathematically we can say that it is used to calculate this & ~(1<<n).Syntax: public BigInteger clearBit(int n) Parameter: The method takes one parameter n which refers to the index of the bit needed to be cleared.Return Value: The method returns the BigInteger after clearing the bit position n.Throws: The method might throw an ArithmeticException when n is negative.Examples: Input: value = 2300, index = 3 Output: 2292 Explanation: Binary Representation of 2300 = 100011111100 bit at index 3 is 1 so clear the bit at index 3 Now Binary Representation becomes 100011110100 and Decimal equivalent of 100011110100 is 2292 Input: value = 5482549, index = 0 Output: 5482548 Below program illustrate the clearBit(index) method of BigInteger(). Java /* *Program Demonstrate clearBit() method of BigInteger */ import java.math.*; public class GFG { public static void main(String[] args) { // Creating BigInteger object BigInteger biginteger = new BigInteger("5482549"); // Creating an int i for index int i = 0; // Call clearBit() method on bigInteger at index i // store the return BigInteger BigInteger changedvalue = biginteger.clearBit(i); String result = "After applying clearbit at index " + i + " of " + biginteger+" New Value is " + changedvalue; // Print result System.out.println(result); } } Output: After applying clearbit at index 0 of 5482549 New Value is 5482548 Reference:https://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html#clearBit(int) Comment More infoAdvertise with us Next Article BigInteger clearBit() Method in Java A AmanSingh2210 Follow Improve Article Tags : Java Java-lang package Java-Functions java-math Java-BigInteger Java-math-package +2 More Practice Tags : JavaJava-BigInteger Similar Reads BigInteger flipBit() Method in Java Prerequisite: BigInteger Basics The java.math.BigInteger.flipBit(index) method returns a BigInteger which is used to flip a particular bit position in a BigInteger. This method Computes (bigInteger ^ (1<<n)). The bit at index n of binary representation of the bigInteger will be flipped. That i 2 min read BigInteger bitCount() Method in Java Prerequisite: BigInteger Basics The java.math.BigInteger.bitCount() method returns number of bits in the two's complement representation of this BigInteger that differ from its sign bit. This method is useful when implementing bit-vector style sets atop BigIntegers.Syntax: public int bitCount() Para 1 min read BigInteger bitLength() Method in Java The java.math.BigInteger.bitLength() method returns the number of bits in the minimal two's-complement representation of this BigInteger, excluding a sign bit. For positive BigIntegers, this is equivalent to the number of bits in the ordinary binary representation. The bitLength method Computes (cei 1 min read BigInteger getLowestSetBit() Method in Java prerequisite : BigInteger Basics The java.math.BigInteger.getLowestSetBit() method returns the index of the rightmost (lowest-order) set bit of this BigInteger. It means this method returns the number of zero or unset bits to the right of the rightmost set bit. If the BigInteger contains no set bit 2 min read BigInteger or() method in Java Prerequisite: BigInteger Basics The java.math.BigInteger.or(BigInteger val) method is used to perform bitwise OR of two BigIntegers. One of the BigInteger is passed in parameter and the other on which the function is called. This method returns a negative number if either of the BigIntegers used wit 2 min read BigInteger and() Method in Java The java.math.BigInteger.and(BigInteger val) method returns a BigInteger whose value is bitwise-AND of two BigIntegers. This method returns a negative number if both of the BigIntegers are negative. The and() method applies bitwise-AND operation upon the current bigInteger and bigInteger passed as p 2 min read BigInteger not() Method in Java The java.math.BigInteger.not() method is used to find the bitwise-NOT of a BigInteger. This method returns a negative value if and only if this BigInteger is non-negative. The BigInteger.not() method apply bitwise Not operation upon the current bigInteger. Syntax: public BigInteger not() Parameters: 1 min read BigInteger xor() Method in Java Prerequisite: BigInteger Basics The xor(BigInteger val) method returns bitwise-XOR of two bigIntegers. This method returns a negative BigInteger if and only if exactly one of the current bigInteger and the bigInteger passed in parameter id negative. The xor() method of BigInteger class apply bitwise 2 min read BigInteger setBit() Method in Java The java.math.BigInteger.setbit(index) method returns a Big-integer whose value is equivalent to this Big-integer with the designated bit set. The method computes (this | (1<<n)). The bit at index n of binary representation of Big-integer will be set means converted to 1. Syntax: public BigInt 2 min read BigInteger andNot() Method in Java The java.math.BigInteger.andNot(BigInteger val) method returns a BigInteger whose value is (this & ~val) where this to the current BigInteger with which the function is being used and val is the bigInteger passed to the function as a parameter. This method, which is equivalent to and(val.not()), 2 min read Like