Description Of BigInteger: flipBit(int n)
The java.math.BigInteger.flipBit(int n) returns a BigInteger whose value is equivalent to this BigInteger with the designated bit flipped. It computes (this ^ (1<<n))BigInteger.flipBit(int n) method returns this ^ (1<<n)
Code Example Java BigInteger
import java.math.BigInteger;
public class BigIntegerExam {
public static void main(String[] args) {
// assign value to bi1
BigInteger bi1 = new BigInteger("8"); // 1000
// perform flipbit operation on bi1 with index 1
BigInteger bi2 = bi1.flipBit(1);
System.out.println(bi2); // output 10
}
}
ไม่มีความคิดเห็น :
แสดงความคิดเห็น