how to generate pi in c

Bryn M. Reeves bmr at redhat.com
Fri Nov 5 16:53:56 UTC 2010


On 11/05/2010 04:40 PM, Arthur Bela wrote:
> Does anyone has a "generate-pi.c" source code?
> 
> Thanks.. :D :\

Any book on numerical algorithms should give you a good run down on how you can
implement this in general. If you're not looking to get too deep into this then
Wikipedia has an article that discusses historical and current methods for
evaluating Pi to a certain degree of accuracy:

http://en.wikipedia.org/wiki/Pi

If you just need the value then the standard C maths library supplies
pre-defined mathematical constants that you can use in your programs:

http://www.gnu.org/s/libc/manual/html_node/Mathematical-Constants.html
http://www.gnu.org/s/libc/manual/html_node/Trig-Functions.html

If none of these satisfies your needs then you'll need to explain what you want
to do with the pi generator in a bit more detail.

Regards,
Bryn.


More information about the users mailing list