解析八进制字符串来创建 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