Pi Number Calculation gives 3.22
<p>I'm trying to calculate pi number using this formula:
pi/4 = 1 - 1/3 + 1/5 - 1/7 + 1/9 ...</p>

<pre><code>   public class Calculator
{
  double process=1;
  double piValue=0;
  int approximation;
  double value;
  public Calculator( int precision)
  {
    approximation = precision;
  }

  public void calculate()
  {
    while(process&lt;=approximation)
    {
      value = 1/(process+2);
      if(process%2==0)
      {
        value = value;
      }
      else
      {
        value = value * (-1);
      }
      piValue = piValue + value;
      process++;
    }
    System.out.println((1+piValue)*4.0);

  }
}
</code></pre>

<p>I see nothing wrong here but i keep getting very meaningless outputs. Here are some examples:</p>

<pre><code>23. step: 3.1490100018286853 This is OK.
1501. step: 3.22874239242146
100,000 step: 3.2274312772602247
</code></pre>

<p>So its limit while "step number" goes to infinity is around 3.22 . How can i fix this problem? </p>

<p>I have just started studying Java, please keep in mind that. </p>

<p>Thanks in advance. </p>