分配给BigInteger数组中的元素时出错 [英] Error assigning to an an element in an array of BigInteger
本文介绍了分配给BigInteger数组中的元素时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的代码.当我创建一个BigInteger
数组并尝试分配一个值时,它会显示一个错误.
This is my code. It shows an error when I create an array of BigInteger
and try to assign a value.
package test;
import java.math.*;
import java.lang.*;
import java.util.*;
public class Test {
public static void main(String[] args) {
BigInteger[] coef = new BigInteger[78];
int a=24;
coef[a]=676557656534345345654645654654645645645645665656567; // Error comes here why
System.out.println(coef[a]);
}
}
推荐答案
始终保持头脑
所有大于2147483647
的数字将不允许输入,因为int范围是-2147483648
至2147483647
(永远不要忘记它).
如果以防万一,您的输出大于限制,它将反转并恢复到最低值,即-2147483648
.
All numbers greater then 2147483647
will not be allowed as input because int range is -2147483648
to 2147483647
(Never forget it).
If just in case your output is greater than the limit it will reverse and to its lowest value i.e -2147483648
.
我建议您使用:
coef[a]=new BigInteger("324576565343453456546456546546456456456455643671");
所有重要功能都在java.lang.Math
类中,您可以通过向其传递字符串来执行算术运算.
All important functions are in java.lang.Math
class and you can perform arithmetic operations by passing a string to it.
这篇关于分配给BigInteger数组中的元素时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文