解析十进制字符串以在 Java 中创建 BigInteger
要解析十进制字符串以创建 BigInteger,只需在 BigInteger 中设置十进制字符串即可。
这是我们的 BigInteger。
BigInteger one; String decStr = "687879"; one = new BigInteger(decStr);
我们来看另一个示例 -
示例
import java.math.*;
public class Demo {
public static void main(String[] args) {
BigInteger one, two;
String decStr = "4373427";
one = new BigInteger("250");
two = new BigInteger(decStr);
System.out.println("Result (BigInteger) : " +one);
System.out.println("Result (Parsing Decimal String) : " +two);
}
}输出
Result (BigInteger) : 250 Result (Parsing Decimal String) : 4373427
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP