3v4l.org

run code in 300+ PHP versions simultaneously
<?php $leftOperand = '-0.00000000099999'; $modulus = '-0.00056'; $scale =14; bcscale($scale); //echo bcmod($leftOperand, $modulus); foreach( [ [4,3,1], [-4,3,2], [-4,-3,1], [4,-3,-2], [3,4,3], [-3,4,1], [-3,-4,1], [3,-4,-1], ] as $d) { echo "\r\nia $d[0] % $d[1] =".iaBcMod($d[0], $d[1], 0). " vs bcmod=".bcmod($d[0], $d[1])." vs wolfman=".$d[2]; } function iaBcMod($leftOperand, $modulus, $scale) { $frac = bcdiv($leftOperand, $modulus, $scale); if( $frac[0] === '-') { return bcsub( $leftOperand, bcmul($modulus, ceil($frac), $scale), $scale ); } return bcsub( $leftOperand, bcmul($modulus, floor($frac), $scale), $scale ); }
Output for git.master, git.master_jit, rfc.property-hooks
ia 4 % 3 =1 vs bcmod=1.00000000000000 vs wolfman=1 ia -4 % 3 =-1 vs bcmod=-1.00000000000000 vs wolfman=2 ia -4 % -3 =-1 vs bcmod=-1.00000000000000 vs wolfman=1 ia 4 % -3 =1 vs bcmod=1.00000000000000 vs wolfman=-2 ia 3 % 4 =3 vs bcmod=3.00000000000000 vs wolfman=3 ia -3 % 4 =-3 vs bcmod=-3.00000000000000 vs wolfman=1 ia -3 % -4 =-3 vs bcmod=-3.00000000000000 vs wolfman=1 ia 3 % -4 =3 vs bcmod=3.00000000000000 vs wolfman=-1

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:
69.97 ms | 1495 KiB | 4 Q