From: michel dot gervais at hrsdc-rhdsc dot gc dot ca
Operating system: win2k
PHP version: 4.4.6
PHP Bug Type: *Math Functions
Bug description: number_format() inconsistant rounding
Description:
------------
number_format(2009.00 * 0.2550,2); = 512.29 <= NOT rounded
----------------
Similar to Bug #22712 << whch has been marked as "bogus/closed" has
actuall errors, as last poster mentions.
<?
echo number_format(63.745, 2, '.', "");
echo number_format(64.745, 2, '.', "");
?>
Result:
63.74
64.75
---------------
Reproduce code:
---------------
number_format(2009.00 * 0.2550,2); = 512.29 << NOT rounded
Should be 519.30
The following 2 lines "are" rounded.
number_format(5949.00 * 0.2550,2); = 1,517.00 << is rounded
number_format(721.00 * 0.2550,2); = 183.86 << is rounded
for some reason it doesn't round 512.29 to 512.30
but it works fine for
1,517.00 => 1,516.99
183.86 => 183.855
------------------------------------------------------------
Code
<? echo number_format(5949.00 * 0.2550,2); ?>
<? echo number_format(2009.00 * 0.2550,2); ?>
<? echo number_format(721.00 * 0.2550,2); ?>
Expected result:
----------------
1,517.00
512.30
183.86
Actual result:
--------------
1,517.00
512.29
183.86
--
Edit bug report at http://bugs.php.net/?id=41065&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=41065&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=41065&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=41065&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=41065&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=41065&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=41065&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=41065&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=41065&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=41065&r=support
Expected behavior: http://bugs.php.net/fix.php?id=41065&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=41065&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=41065&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=41065&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41065&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=41065&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=41065&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=41065&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=41065&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=41065&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=41065&r=mysqlcfg