我期待任何小數四捨五入到下一個數字。像1.199 答案應該是或類似1.99也應該圍捕十進制到下一個數字在PHP
這是迄今爲止我發現了什麼
echo(round(1.4,0,PHP_ROUND_HALF_UP) . "<br>");
echo(round(-1.4,0,PHP_ROUND_HALF_UP) . "<br>");
//Answer = 1
//Answer = -1
echo(round(1.4,0,PHP_ROUND_HALF_DOWN) . "<br>");
echo(round(-1.4,0,PHP_ROUND_HALF_DOWN) . "<br>");
//Answer = 1
//Answer = -1
echo(round(1.4,0,PHP_ROUND_HALF_EVEN) . "<br>");
echo(round(-1.4,0,PHP_ROUND_HALF_EVEN) . "<br>");
//Answer = 1
//Answer = -1
echo(round(1.4,0,PHP_ROUND_HALF_ODD) . "<br>");
echo(round(-1.,0,PHP_ROUND_HALF_ODD));
//Answer = 1
//Answer = -1
所以'1.01'也應該是2? – Qirel
使用[''ceil()'](http://php.net/manual/en/function.ceil.php)函數。 –