how to calculate value of pi in php till 100000 decimal numbers.. or may be more
A:
Calculating PI in php?
Why calculate when we already have the M_PI
constant?
M_PI
contains the value 3.14159265358979323846
.
10000 decimal places for PI is quite a number.
thephpdeveloper
2009-11-24 07:55:20
Apparently you can set the precision of `pi()`/`M_PI` in php.ini. Not sure if it goes to 11^H 100K though. :) http://php.net/manual/en/function.pi.php
deceze
2009-11-24 09:21:06
Too bad, apparently it only goes to 48, on my system at least. :)
deceze
2009-11-24 09:34:33
thanks to deceze for working that out!
thephpdeveloper
2009-11-24 10:05:00
calculating pi is a useful cpu benchmark.
Rob
2009-11-24 12:07:50
+2
A:
See here for an algorithm in PHP: http://mgccl.com/2007/01/22/php-calculate-pi-revisited
Konamiman
2009-11-24 07:56:21
+1
A:
- Find a website with Pi to 100000 places (okay, here)
- Copy-paste into PHP as a string.
- Echo string.
DisgruntledGoat
2009-11-24 12:00:47
I was just being facetious. I don't get why you would ever want to calculate pi in PHP.
DisgruntledGoat
2009-11-25 12:26:20