JAVA的BigInteger

来源:互联网 发布:linux下解压rpm文件 编辑:程序博客网 时间:2024/06/05 05:39

  在刷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;//商








0 0
原创粉丝点击