在Java中右移BigInteger
要在BigInteger中右移,使用shiftRight()方法。
java.math.BigInteger.shiftRight(int n)会返回一个BigInteger,其值为 (this >> n)。将执行有符号扩展。移动距离n可能为负,在这种情况下,此方法将执行左移。它计算floor(this / 2n)。
以下是一个示例 -
示例
import java.math.*;
public class Demo {
public static void main(String[] args) {
BigInteger one;
one = new BigInteger("25");
one = one.shiftRight(3);
System.out.println("Result: " +one);
}
}输出
Result: 3
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C编程
C++
C#
MongoDB
MySQL
Javascript
PHP