Pi - Hm, somethign is not right here.

ok, here is my formula

PHP Code:

```
[CODE]/* Pi loops, we how many times??? */
```

while ( cycles < loops ) { // While x is less than 10

cycles += 1; /* 1 loop started. */

pi += (plus * (1 / ((2 * cycles) + 1)));

plus = (0 - plus);

/* tempPi = ((1 - pi) * 4); */

/* system("cls"); */

/* progress = ((cycles / loops) * 100) */;

printf("%.0f / %.0f\n",cycles,loops);

}

/* Done, end of loading */

system("cls");

/* Calculate pi (1)*/

pi = (4 * (1 - pi));[/CODE]

I am using this formula

http://upload.wikimedia.org/math/9/e...d1d52205a9.png

---

I have several problems.

The main one

1 - Can I increase the number of decimal places - I am using float ( I get 3.141637086828610000000000000000000000000000000000 ?

2 - Why does it not give me the answer I expect - (I expect 3.14159265358...) (I tried with 2 million cycles).

- probably a bad wording, what is meant here is a question about how c++ works. Is there a limit to the decimals place during a calculation?

3 - math based, is there a better formula that i can use? I know there are other forumlas around but this one seems to be the one they recommend for programming.

---

This is not homework as such, I am not wanting someone to re-write it for me with a better formula and code as I am trying to do this to learn. Because it is not homework, I am willing to change to another language if it is free, similar syntax and is not too hard to learn.

---

Thanks

Anthony