getLowestSetBit(): This method is available in java.math.BigInteger class of Java.
Syntax:
int java.math.BigInteger.getLowestSetBit()
This method returns the index of the rightmost (lowest-order) one bit in this BigInteger (the number of zero bits to the right of the rightmost one bit). Returns -1 if this BigInteger contains no one bit.(Computes (this == 0? -1 : log2(this & -this)).)
Returns: index of the rightmost one bit in this BigInteger.
For Example:
BigInteger bigInteger = new BigInteger("1234")
bigInteger.getLowestSetBit() = > It returns 1.
Approach
Java
import java.math.BigInteger;public class BigIntegergetLowestSetBit {public static void main(String[] args) {BigInteger bigInteger = new BigInteger("1234");System.out.println(bigInteger.getLowestSetBit());}}
Output:
1
No comments:
Post a Comment