使用靜態的 valueOf方法可以將普通的數值轉換爲大數值:
Biglnteger a = Biglnteger.valueOf(100);
大數值的操作有其相應的函數,不能直接用運算符
Biglnteger add(Biglnteger other)
Biglnteger subtract(Biglnteger other)
Biglnteger multipiy(Biginteger other)
Biglnteger divide(Biglnteger other)
Biglnteger mod(Biglnteger other)
返冋這個大整數和另一個大整數 other的和、 差、 積、 商以及餘數。
int compareTo(Biglnteger other)
如果這個大整數與另一個大整數 other 相等, 返回 0; 如果這個大整數小於另一個大整數 other, 返回負數; 否則, 返回正數。
static Biglnteger valueOf(long x)
返回值等於 x 的大整數。
BigDecimal add(BigDecimal other)
BigDecimal subtract(BigDecimal other)
BigDecimal multipiy(BigDecimal other)
BigDecimal divide(BigDecimal other RoundingMode mode) 5.0
返回這個大實數與另一個大實數 other 的和、 差、 積、 商。要想計算商, 必須給出舍入方式 ( rounding mode。) RoundingMode.HALF UP 是在學校中學習的四捨五入方式( BP , 數值 0 到 4 捨去, 數值 5 到 9 進位)。它適用於常規的計算。有關其他的舍入方式請參看 Api文檔。
int compareTo(BigDecimal other)
如果這個大實數與另一個大實數相等, 返回 0 ; 如果這個大實數小於另一個大實數,返回負數;否則,返回正數。
static BigDecimal valueOf(long x)
static BigDecimal valueOf(long x ,int scale)
返回值爲 X 或 x / 10scale 的一個大實數。