使用静态的 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 的一个大实数。