java中的一个大整数输入

时间:2012-09-30 06:39:10

标签: java

  

可能重复:
  Large Numbers in Java

我需要使用< = 500位数来获取和操作整数输入。如何在java中完成?任何帮助,将不胜感激。

2 个答案:

答案 0 :(得分:2)

BigInteger课程是开始大in的好地方。

我必须查看文档以了解BigInteger的上限是什么,但它应该符合您的需求。

答案 1 :(得分:1)

import java.math.BigInteger;
public class BigIntegerExample 
{
    public static void main(String[] args) 
    {
       BigInteger bigInteger1 = new BigInteger ("123456789");
       BigInteger bigInteger2 = new BigInteger ("112334");
       BigInteger bigIntResult = bigInteger1.multiply(bigInteger2); 
       System.out.println("Result is  ==> " + bigIntResult);
    }
}

您可以使用Biginteger类在整数中取长值。