欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

关于BigInteger的加减乘除使用

发布时间:2025/3/11 编程问答 37 豆豆
生活随笔 收集整理的这篇文章主要介绍了 关于BigInteger的加减乘除使用 小编觉得挺不错的,现在分享给大家,帮大家做个参考.
public static void main(String[] args) {BigInteger bg1 = new BigInteger("12345678912");// int类型转BigIntegerint value = 12345678912;BigInteger bg2 = BigInteger.valueOf(value);//1.加法System.out.println(bg1.add(bg2));//2.减法System.out.println(bg1.subtract(bg2));//3.乘法System.out.println(bg1.multiply(bg2));//4.除法System.out.println(bg2.divide(bg1));System.out.println("--------------");//5.取除数和余数的数组BigInteger[] bg_arry = bg2.divideAndRemainder(bg1);for(int i=0; i< bg_arry.length; i++) {System.out.println(bg_arry[i]);}}

总结

以上是生活随笔为你收集整理的关于BigInteger的加减乘除使用的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。