3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $number = 3.0000000000000002; $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 "Rounded result: ".$roundedResult.PHP_EOL; echo "Inted result: ".$intedResult.PHP_EOL;
Output for 4.3.10 - 4.4.9, 5.0.2 - 7.1.0
Rounded result: 3 Inted result: 3
Output for 4.3.0 - 4.3.9, 5.0.0 - 5.0.1
Rounded result: 3PHP_EOLInted result: 3PHP_EOL