在Java中,我希望能够对非常大的整数(不能存储在long中)进行操作,我该怎么做?
在表现良好的情况下,处理这个问题的最佳方法是什么?我应该创建自己的包含多个长变量的数据类型吗?
Example:
public class MyBigInteger{
private long firstPart;
private long secondPart;
...
}
public MyBigInteger add(long a, long b){
MyBigInteger res;
// WHAT CAN I DO HERE, I guess I could do something with the >> << operators, but I've never used them!
return res;
}
Thanks!
您应该检查大整数 http://download.oracle.com/javase/6/docs/api/java/math/BigInteger.htmljava 类。它正是您所需要的。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)