I\'trying to convert a float to an int value in php:
var_dump((int)(39.3 * 100.0)); //Returns 3929 but should be 3930!
var_dump((int)(39.2 * 100.0)); //Retur
This might be late but the proper way to do it is as follows:
(int) bcmul(39.3, 100.0); // 3930
(int) bcmul(39.2, 100.0); // 3920
and for dealing with digits / calculation for floats, or anything that involves money transaction, you should never use directly multiplication/division + casting.
please refer to this as well:
http://php.net/manual/en/book.bc.php
notice: the casting in my answer is just to convert String to Int, (you don't need to do it)