3v4l.org

run code in 300+ PHP versions simultaneously
<?php function calcPi($precision){ $limit = ceil(log($precision)/log(2))-1; bcscale($precision+6); $a = 1; $b = bcdiv(1,bcsqrt(2)); $t = 1/4; $p = 1; for($n = 0; $n < $limit; $n++){ $x = bcdiv(bcadd($a,$b),2); $y = bcsqrt(bcmul($a, $b)); $t = bcsub($t, bcmul($p,bcpow(bcsub($a,$x),2))); $a = $x; $b = $y; $p = bcmul(2,$p); } return bcdiv(bcpow(bcadd($a, $b),2),bcmul(4,$t),$precision); } echo calcPi(100);
Output for git.master, git.master_jit, rfc.property-hooks
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
43.05 ms | 401 KiB | 8 Q