# I want more data!

• 04-09-2003
CodeMonkey
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).
• 04-09-2003
Munkey01
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?
• 04-09-2003
djiialnle
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.

:rolleyes:
• 04-09-2003
LuckY
What's with all the monkeys
• 04-09-2003
Munkey01
I got my name from some of my personal aspects (I am a little on the hairy side).
• 04-09-2003
Bingo The Clown
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.
• 04-12-2003
CodeMonkey
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 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.
• 04-12-2003
confuted
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
• 04-12-2003
confuted

• 04-12-2003
roktsyntst
Quote:

Originally posted by blackrat364

Or:
http://mathworld.wolfram.com/PiFormulas.html
• 04-13-2003
CodeMonkey
Hey, cool... thanks rokt.
Here, could anbody explain to me what the output of pi is supposed to mea in this console (my program):