3v4l.org

run code in 300+ PHP versions simultaneously
<?php function round_up($val) { return ceil(bcdiv(bcmul($val, 100, 2)), 100, 2); } $a = 5.4; $b = 48; var_dump($a * $b); var_dump(bcmul($a, $b, 2) * 1); var_dump(round_up($a * $b)); var_dump(round_up(bcmul($a, $b, 2))); echo "\n"; $a = 5.4; $b = 48.13; var_dump($a * $b); var_dump(bcmul($a, $b, 2) * 1); var_dump(round_up($a * $b)); var_dump(round_up(bcmul($a, $b, 2))); ?>
Output for 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
float(259.20000000000005) float(259.2) Fatal error: Uncaught ArgumentCountError: bcdiv() expects at least 2 arguments, 1 given in /in/dW7eh:5 Stack trace: #0 /in/dW7eh(5): bcdiv('25920.00') #1 /in/dW7eh(12): round_up(259.2) #2 {main} thrown in /in/dW7eh on line 5
Process exited with code 255.
Output for 8.0.13
float(259.20000000000005) Fatal error: Uncaught Error: Call to undefined function bcmul() in /in/dW7eh:11 Stack trace: #0 {main} thrown in /in/dW7eh on line 11
Process exited with code 255.
Output for 7.0.5, 7.3.32 - 7.3.33, 7.4.33
float(259.2) Fatal error: Uncaught Error: Call to undefined function bcmul() in /in/dW7eh:11 Stack trace: #0 {main} thrown in /in/dW7eh on line 11
Process exited with code 255.
Output for 5.5.24 - 5.5.28, 5.5.31 - 5.5.33, 5.5.35, 5.6.8 - 5.6.12, 5.6.16 - 5.6.19, 5.6.21 - 5.6.28, 7.0.0 - 7.0.4, 7.0.6 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.32
float(259.2) float(259.2) Warning: bcdiv() expects at least 2 parameters, 1 given in /in/dW7eh on line 5 Warning: ceil() expects exactly 1 parameter, 3 given in /in/dW7eh on line 5 NULL Warning: bcdiv() expects at least 2 parameters, 1 given in /in/dW7eh on line 5 Warning: ceil() expects exactly 1 parameter, 3 given in /in/dW7eh on line 5 NULL float(259.902) float(259.9) Warning: bcdiv() expects at least 2 parameters, 1 given in /in/dW7eh on line 5 Warning: ceil() expects exactly 1 parameter, 3 given in /in/dW7eh on line 5 NULL Warning: bcdiv() expects at least 2 parameters, 1 given in /in/dW7eh on line 5 Warning: ceil() expects exactly 1 parameter, 3 given in /in/dW7eh on line 5 NULL
Output for 5.5.29 - 5.5.30, 5.5.34, 5.6.13 - 5.6.15, 5.6.20
float(259.2) Fatal error: Call to undefined function bcmul() in /in/dW7eh on line 11
Process exited with code 255.

preferences:
219.49 ms | 402 KiB | 226 Q