title: java.lang.StackOverflowError exception for large inputs
body: <p>Basically, I'm writing a program to do a simple division manually where I want the decimal place upto 10^6 places. The program works for inputs &lt;3000, but when I go higher, it shows:
  <code>Exception in thread "main" java.lang.StackOverflowError</code></p>
  
  <p>Here's my code:</p>
  
  <pre><code>{
  ....
  ....
  int N=100000;//nth place after decimal point
  String res=obj.compute(N,103993.0,33102.0,ans); //division of 103993.0 by 33102.0
  System.out.println(res);
  }
  
  public String compute (int n, double a, double b, String ans){
          int x1=(int)a/(int)b;
          double x2=a-x1*b;
          double x3=x2*10;
          int c=0;
          if (n==0||n&lt;0)
              return ("3."+ans.substring(1));
          else if (x3&gt;b){
              ans+=""+x1;
              c=1;
          }
          else if(x3*10&gt;b){
              ans+=x1+"0";
              c=10;
          }
          else if(x3*100&gt;b){
              ans+=x1+"00";
              c=100;
          }
          else if(x3*1000&gt;b){
              ans+=x1+"000";
              c=1000;
          }
          else if(x3*10000&gt;b){
              ans+=x1+"0000";
              c=10000;
          }
          return compute(n-String.valueOf(c).length(),x3*c,b,ans);
      }
  </code></pre>
  
  <p>I'm not any hard-core programmer of Java. I need help in tackling this situation. I read some SO posts about increasing the stack size, but I didn't understand the method. </p>