I have a situation where I cast a double variable to integer. and its giving me wrong result. Why is this happening?
>>> $amount = (double) 1052.10
=> 1052.1
>>> $amount = $amount * 100;
=> 105210.0
>>> (int) $amount;
=> 105209 // weird
I am able to fix it by rounding the variable first ( ie: (int) round($amount)
),
But still, I wonder why is this happening?
using PHP 7.2.9