在 Java 中左移 BigInteger
要在 BigInteger 中左移,请使用 shiftLeft() 方法。
java.math.BigInteger.shiftLeft(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.shiftLeft(3);
System.out.println("Result: " +one);
}
}输出
Result: 200
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP