Description Of BigInteger: clearBit(int n)
The
java.math.BigInteger.clearBit(int n) The java.math.BigInteger.clearBit(int n) returns a BigInteger whose value is equivalent to this BigInteger with the designated bit cleared. It computes (this & ~(1<<n)).
Code Example Java BigInteger
import java.math.BigInteger;
public class BigIntegerExam {
public static void main(String[] args) {
BigInteger bi1 = new BigInteger("7");
System.out.println(bi1.clearBit(2)); // 3
// 7 = 111, 111 << 2 = 11100, ~11100 = 00011, 111 & 00011 = 00011 = 3
int testbit = 7; // 111 , 7 << 1 = 14 = 1110, 7 << 2 = 28 = 11100
System.out.println(testbit << 2); // 28
}
}
ไม่มีความคิดเห็น :
แสดงความคิดเห็น