clearBit(): This method is available in java.math.BigInteger class of Java.
Syntax:
BigInteger java.math.BigInteger.clearBit(int n)
This method takes one argument of type int as its parameter. It returns a BigInteger whose value is equivalent to this BigIntegerwith the designated bit cleared.(Computes (this & ~(1<<n)).)
Parameters: One parameter is required for this method.
n: index of the bit to clear.
Returns: this & ~(1<<n).
Throws: ArithmeticException - n is negative.
For Example:
BigInteger bigInteger = new BigInteger("1234")
n = 4
bigInteger.clearBit(n) = > It returns 1218.
Approach
Java
import java.math.BigInteger;public class BigIntegerclearBit {public static void main(String[] args) {BigInteger bigInteger = new BigInteger("1234");int n = 4;System.out.println(bigInteger.clearBit(n));}}
Output:
1218
No comments:
Post a Comment