3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo "This is the problem, im expecting 1012". PHP_EOL; echo intval((floatval("10.12") * 100)) . PHP_EOL; //1011 echo "Just Floatval". PHP_EOL; echo (floatval("10.12") * 100) . PHP_EOL; //1012 echo "Convert to string (other number)". PHP_EOL; echo intval((floatval("11.12") * 100)) . PHP_EOL; //1112 echo "Convert to string (other number)". PHP_EOL; echo intval((floatval("10.13") * 100)) . PHP_EOL; //1013 echo "Use bcmul instead". PHP_EOL; echo bcmul("10.12", 100) . PHP_EOL; //1012
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.32, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27, 8.4.1 - 8.4.14
This is the problem, im expecting 1012 1011 Just Floatval 1012 Convert to string (other number) 1112 Convert to string (other number) 1013 Use bcmul instead 1012
Output for 7.4.33
This is the problem, im expecting 1012 1011 Just Floatval 1012 Convert to string (other number) 1112 Convert to string (other number) 1013 Use bcmul instead Fatal error: Uncaught Error: Call to undefined function bcmul() in /in/cnIfL:16 Stack trace: #0 {main} thrown in /in/cnIfL on line 16
Process exited with code 255.

preferences:
147.59 ms | 407 KiB | 5 Q