可以帮我看看这个计算吗?它假设回声 “等于” ...但它给我 “不等于”PHP简单数学计算
<?php
$tl_pax = 1;
$ct_pax = 2;
$at_pax = 2;
$a = 0.5;
$b = 0.2;
$c = 0.2;
$d = 0.2;
$e = 0.2;
$f = 0.2;
$g = 0.2;
$h = 0.9;
$sum = $a + $b + $c + $d + ($e * $tl_pax) + ($f * $ct_pax) + ($g * $at_pax) + $h;
$total = 3;
if($total == $sum){
echo 'equal: ' . $sum . ' - ' . $total;
}
else{
echo 'not equal: ' . $sum . ' - ' . $total;
}
?>
什么是输出总和与总的范围? –
[Floating point miscuracy examples]可能的重复(http://stackoverflow.com/questions/2100490/floating-point-inaccuracy-examples) – Gordon