3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $number = 3.0000000002; $precision = 8; $delta = pow(0.1, $precision); $rounded = round($number, $precision); if (abs($number -$rounded) < $delta) { $roundedResult = intval($number); } if ((int) $number == $number){ $intedResult = (int) $number; } echo "Source number: ".$number.PHP_EOL; echo "Rounded result: ".$roundedResult.PHP_EOL; echo "Inted result: ".$intedResult.PHP_EOL;
Output for 5.0.4 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Source number: 3.0000000002 Rounded result: 3 Notice: Undefined variable: intedResult in /in/MpTcR on line 26 Inted result:
Output for 4.3.10 - 4.4.9, 5.0.2 - 5.0.3
Source number: 3.0000000002 Rounded result: 3 Notice: Undefined variable: intedResult in /in/MpTcR on line 26 Inted result:
Output for 4.3.0 - 4.3.9, 5.0.0 - 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/MpTcR on line 24 Source number: 3.0000000002PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/MpTcR on line 25 Rounded result: 3PHP_EOL Notice: Undefined variable: intedResult in /in/MpTcR on line 26 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/MpTcR on line 26 Inted result: PHP_EOL