<?php
$last_percent = 0;
$as = array("110.800002098083", "30", "36.1499996185303", "11", "13", "13.9899997711182", "74.5200042724609", "13.9899997711182");
$t = 304.46000552177;
foreach($as as $a) {
$last_percent += round($a*100/$t, 2);
}
var_dump($last_percent);
$last_percent = 100 - $last_percent;
var_dump($last_percent);
?>
为什么结果是0.33000000000001?为什么它只发生在100和99?如果我使用$ last_percent = 90 - $ last_percent; 结果是-9.67PHP疯狂bug
浮动。点。数学。 – rdlowrey
[每个计算机科学家应该知道的关于浮点算术](http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html) – sachleen
http://php.net/manual/ en/language.types.float.php < - 有一个带有警告的大红色框。阅读。 – hakre