adding two very large numbers
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/3748846/how-to-add-two-numbers-of-any-length-in-java">How to add two numbers of any length in java?</a>  </p>
</blockquote>



<p>can anyone help me with this?</p>

<p>what i need to do is to add a very large number that a calculator doesn't hold.</p>

<p>this is the code i have though it can only hold a number until 2147483647.. any number higher than that i get the error message stating "integer number too large"</p>

<p>can anyone tell me how can i use a larger number?</p>

<pre><code>import java.math.BigDecimal;

public class AddTwoBigNumbers{
  public static void main() {
  BigDecimal num1, num2;
  num1 = new BigDecimal(2147483647);
  num2 = new BigDecimal(2147483647);
  Sum(num1, num2);
  }

  public static void Sum(BigDecimal val1, BigDecimal val2){
  BigDecimal sum = val1.add(val2);
  System.out.println("Sum of two BigDecimal numbers: "+ sum);
  }
}
</code></pre>
