可以幫我看看這個計算嗎?它假設回聲 「等於」 ...但它給我 「不等於」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