解析八進位制字串來建立 Java 中的大整型
To parse the octal string to create BigInteger, use the following BigInteger constructor and set the radix as 8 for Octal −
BigInteger(String val, int radix)
此建構函式用於將特定基數的 BigInteger 字串表示翻譯成 BigInteger。
在以下示例中,我們設定了 BigInteger 而基數設為 8。
BigInteger one, two;
one = new BigInteger("12");
two = new BigInteger("4373427", 8);以下就是完整的示例 −
示例
import java.math.*;
public class Demo {
public static void main(String[] args) {
BigInteger one, two;
one = new BigInteger("12");
two = new BigInteger("4373427", 8);
System.out.println("Result (BigInteger) : " +one);
System.out.println("Result (Parsing Octal String) : " +two);
}
}結果
Result (BigInteger) : 12 Result (Parsing Octal String) : 1177367
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
安卓
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP