I'm having issue with this particular number 10.12
when converting it to integer. Below is the code snippet of what I have tried and what is the result. Please advise if this is a bug and if I can help to report it.
<?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
I've also created a snippet at https://3v4l.org/cnIfL