What's wrong with php floats?
$v = 5.2 * 3;
if($v==15.6) {
echo 'Everything is fine =)';
} else {
echo 'Okay something is wrong :S';
var_dump($v); // float 15.6
}
Check this out too:
$v = 5.2 * 3;
if($v>15.6 AND $v<15.60000000001) {
echo 'We are doomed :S';
var_dump($v); // float 15.6
} else {
echo 'Everything is fine =)';
}
I guess it has something to do with the internal representation or some obscure low level stuff? If that's the case, how do I get around this issue?
Anything else I should know before using this to calculate real money transactions?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…