解析十進位制字串以在 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