So I am reading the php manual on its types and am playing around with them. I have:
var_dump((int)0.8 + 0.2)
why does this return 0.2
?
I have no idea why.
So I am reading the php manual on its types and am playing around with them. I have:
var_dump((int)0.8 + 0.2)
why does this return 0.2
?
I have no idea why.
It first evaluates (int)0.8
, which is 0, then it adds 0.2. You need to use,
var_dump((int)(0.8 + 0.2))