您的位置:首页 > 编程语言 > Java开发

JAVA的BigInteger

2016-02-11 19:55 507 查看
  在刷PAT的题目时,碰到测试用例数据可能超过long型最大数值的情况,比如下面这道题目的测试用例

       xxx1002的链接

       之后,改用BigInteger

       记录一些其特性

1.简单的数字转换成BigInteger,比如上面的文章中,需要得到一个数字“10”的BigInteger

new bi10 = new BigInteger("10");

2.再从BigInteger转换成Int型

int a = bi10.intValue();3.求余数
BigInteger[] result = number.divideAndRemainder(bi10);
int a = result[1].intValue(); //余数
int b = result[0].intValue;//商
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: