3v4l.org

run code in 300+ PHP versions simultaneously
<?php function bround($dVal,$iDec) { // banker's style rounding or round-half-even // (round down when even number is left of 5, otherwise round up) // $dVal is value to round // $iDec specifies number of decimal places to retain static $dFuzz=0.00001; // to deal with floating-point precision loss $iRoundup=0; // amount to round up by $iSign=($dVal!=0.0) ? intval($dVal/abs($dVal)) : 1; $dVal=abs($dVal); // get decimal digit in question and amount to right of it as a fraction $dWorking=$dVal*pow(10.0,$iDec+1)-floor($dVal*pow(10.0,$iDec))*10.0; $iEvenOddDigit=floor($dVal*pow(10.0,$iDec))-floor($dVal*pow(10.0,$iDec-1))*10.0; if (abs($dWorking-5.0)<$dFuzz) $iRoundup=($iEvenOddDigit & 1) ? 1 : 0; else $iRoundup=($dWorking>5.0) ? 1 : 0; return $iSign*((floor($dVal*pow(10.0,$iDec))+$iRoundup)/pow(10.0,$iDec)); } echo bround(10.005); ?>
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught ArgumentCountError: Too few arguments to function bround(), 1 passed in /in/F40HV on line 21 and exactly 2 expected in /in/F40HV:3 Stack trace: #0 /in/F40HV(21): bround(10.005) #1 {main} thrown in /in/F40HV on line 3
Process exited with code 255.

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:
53.44 ms | 401 KiB | 8 Q