Description Of BigInteger: shiftRight(int n)
The java.math.BigInteger.shiftRight(int n) BigInteger whose value is (this >> n) . Sign extension is performed. The shift distance, n , may be negative, in which case this method performs a left shift. (Computes floor(this * 2n))BigInteger.shiftRight(int n) method returns this >> n
Code Example Java BigInteger
import java.math.BigInteger;
public class BigIntegerExam {
public static void main(String[] args) {
BigInteger bi1 = new BigInteger("10");
// perform rightshift operation on bi1 using 2 and -2
BigInteger bi2 = bi1.shiftRight(2);
BigInteger bi3 = bi1.shiftRight(-2);
System.out.println(bi2);
System.out.println(bi3);
}
}
ไม่มีความคิดเห็น :
แสดงความคิดเห็น