|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2014-02-18 20:30 UTC] mail at daniel-berlin dot de
[2014-02-18 20:55 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
[2014-02-18 20:55 UTC] requinix@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 11:00:01 2025 UTC |
Description: ------------ 5.5 is wrongly rounded to 5 (even with PHP_ROUND_HALF_UP) Test script: --------------- <?php $n = 2.2459431618637; echo "Expected 5.5 / is " . round(pow(1024, $n - floor($n)), 2, PHP_ROUND_HALF_UP) . "\n"; echo "Expected 5.5 / is " . round(pow(1024, $n - floor($n)), 1, PHP_ROUND_HALF_UP) . "\n"; echo "Expected 6 / is " . round(pow(1024, $n - floor($n)), 0, PHP_ROUND_HALF_UP) . "\n"; echo "Expected 5.50 / is " . number_format(pow(1024, $n - floor($n)), 2) . "\n"; echo "Expected 5.5 / is " . number_format(pow(1024, $n - floor($n)), 1) . "\n"; echo "Expected 6 / is " . number_format(pow(1024, $n - floor($n)), 0) . "\n"; Expected result: ---------------- See output (line 3 and 6 are wrong): Expected 5.5 / is 5.5 Expected 5.5 / is 5.5 Expected 6 / is 5 Expected 5.50 / is 5.50 Expected 5.5 / is 5.5 Expected 6 / is 5 Actual result: -------------- See expected result.