i don't know.
check it against tuts here- http://www.cprogramming.com/tutorial.html
Hello. I was bored and decided to make a program for windows to calculate pi, but its not working...
ok, heres what i wrote:
it just prints out 3 repeatedly!Code:#include <iostream> int main() { using namespace std; long double pi; unsigned long int denom; bool subtract; denom = 1; subtract = true; pi = 4; while(true) { cout << pi; cout << "\n"; if (subtract == true) { denom = denom + 2; pi = pi-4/denom; subtract = false; } else { denom = denom + 2; pi = pi+4/denom; subtract = true; } } return 0; }
it seems like it's rounding off everything. Is there any way I can stop this from happening and can anyone tell me WHY this is happening?
I dont really need it for calculating pi, i have around 90 digits memorized
I just need to work on my programming skills....
thats the whole reason for this program.
(please dont just read this and then hit the back button without saying something)
i don't know.
check it against tuts here- http://www.cprogramming.com/tutorial.html
I know some C++, but not enough to actually help anyone...
...Oh and your code is horrible!![]()
make both pi and denom an unsigned long double, or just add a .0 to the end of the 4. The problem is that it's getting turned back into an int because it thinks it doesn't need the precision.
If anyone is looking to buy, sell, trade games and support a developer directly at the same time, consider joining Goozex. Enjoy!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks