# Thread: I want more data!

1. ## I want more data!

Hola. I'm writing (or have finished writing) a program that calculates pi. It works very well, except that the output is limited to 10 decimal places, with a long double. So, I was wondering if there were some variable or macro or template or something that would simple accommodate for any amount of data (given the necessary memory).

2. You may not need to assign the value to a variable if you designed it a different way. How about showing some code on how you are calculating it?

3. Could you use a recursive function to display an integer with each step? You would have to set some global constant to the number of decimal places you wanted.

Just a thought.

4. What's with all the monkeys

5. I got my name from some of my personal aspects (I am a little on the hairy side).

6. Just a thought, but could you reasign the long double with the newly calculated addition to pie after the previous had been printed on the screen. I'm not completly sure about the decimal place and all that, but it might work.

7. Hmmm. Yes, I'll post some code as soon as I can get to my computer (on a friend's). The thing is, calculations require square roots, which are always appx, so I just want to be able to be as accurate as possible.
I'll give you a rundown of how the program works, it's pretty simple:
-Ask the user for the length of the radius

-Ask the user for resolution (a value .001 - 100)

-Loop through x values, incremental to the resolution given, and find their respective y coordinates using the circle formula (the center is 0,0). While this is happening, for every two points calculated, the distance between them is calculated and added to variable 'circ'. The loop ends when the increments (increasing at a rate of 'resolution') equal the radius. What we now have is one-fourth the circumfrence of a pseudo-circle. It is divided by two-times the radius to yield PI.

AND IT WORKS. The only problem is, it will only work to the limit of certain datatype restrictions, which is why I posted my question. I hope to have the code up soon.

*Edit* By the way: I'm a monkey because I like being a monkey.

8. I don't know exactly how to go about doing it, but I believe that it is possible to just allocate yourself a huge chunk of memory and then program all of the math operations that you need to do with it...someone around here can give you more info than I can, I'm sure.

edit: I usually go with 3.14159265358979323846 from memory, but you could also check out http://www.cecm.sfu.ca/pi/pi.html

9. Also, to ease your computations...

Pi/4= 1-(1/3)+(1/5)-(1/7)+(1/9)-(1/11)+(1/13)-(1/15)...ad infinitum

10. Originally posted by blackrat364
Also, to ease your computations...

Pi/4= 1-(1/3)+(1/5)-(1/7)+(1/9)-(1/11)+(1/13)-(1/15)...ad infinitum
Or:
http://mathworld.wolfram.com/PiFormulas.html

11. Hey, cool... thanks rokt.
Here, could anbody explain to me what the output of pi is supposed to mea in this console (my program):

Popular pages Recent additions