在 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