From:             
Operating system: Linux ubuntu 11.04
PHP version:      5.3.10
Package:          Math related
Bug Type:         Bug
Bug description:money_format round error

Description:
------------
if you round with money_format, some small numbers with 0.005 are rounded
down instead of up.

Numbers bigger than 63.5 are all rounded falsly down like with floor()



Test script:
---------------
for($i=0;$i<70;$i++) {
echo($i.'.005 =>'.money_format('%.2i',$i+0.005).'<br>');
if($i<10)
echo($i.'.00500000000000001=>'.money_format('%.2i',$i+0.00500000000000001).'<br>');
} 

Expected result:
----------------
0.005 =>0.01
0.00500000000000001=>0.01
1.005 =>1.01
1.00500000000000001=>1.01
2.005 =>2.01
2.00500000000000001=>2.01
3.005 =>3.01
3.00500000000000001=>3.01
4.005 =>4.01
4.00500000000000001=>4.01
5.005 =>5.01
5.00500000000000001=>5.01
6.005 =>6.01
6.00500000000000001=>6.01
7.005 =>7.01
7.00500000000000001=>7.01
8.005 =>8.01
8.00500000000000001=>8.01
9.005 =>9.01
9.00500000000000001=>9.01
10.005 =>10.01
11.005 =>11.01
12.005 =>12.01
13.005 =>13.01
14.005 =>14.01
15.005 =>15.01
16.005 =>16.01
...

Actual result:
--------------
0.00500000000000001=>0.01
1.005 =>1.00
1.00500000000000001=>1.01
2.005 =>2.00
2.00500000000000001=>2.00
3.005 =>3.00
3.00500000000000001=>3.00
4.005 =>4.00
4.00500000000000001=>4.00
5.005 =>5.00
5.00500000000000001=>5.00
6.005 =>6.00
6.00500000000000001=>6.00
7.005 =>7.00
7.00500000000000001=>7.00
8.005 =>8.01
8.00500000000000001=>8.01
9.005 =>9.01
9.00500000000000001=>9.01
10.005 =>10.01
11.005 =>11.01
12.005 =>12.01
13.005 =>13.01
14.005 =>14.01
15.005 =>15.01
16.005 =>16.00
17.005 =>17.00
18.005 =>18.00
19.005 =>19.00
20.005 =>20.00
21.005 =>21.00
22.005 =>22.00
23.005 =>23.00
24.005 =>24.00
25.005 =>25.00
26.005 =>26.00
27.005 =>27.00
28.005 =>28.00
29.005 =>29.00
30.005 =>30.00
31.005 =>31.00
32.005 =>32.01
33.005 =>33.01
34.005 =>34.01
35.005 =>35.01
36.005 =>36.01
37.005 =>37.01
38.005 =>38.01
39.005 =>39.01
40.005 =>40.01
41.005 =>41.01
42.005 =>42.01
43.005 =>43.01
44.005 =>44.01
45.005 =>45.01
46.005 =>46.01
47.005 =>47.01
48.005 =>48.01
49.005 =>49.01
50.005 =>50.01
51.005 =>51.01
52.005 =>52.01
53.005 =>53.01
54.005 =>54.01
55.005 =>55.01
56.005 =>56.01
57.005 =>57.01
58.005 =>58.01
59.005 =>59.01
60.005 =>60.01
61.005 =>61.01
62.005 =>62.01
63.005 =>63.01
64.005 =>64.00
65.005 =>65.00
66.005 =>66.00
67.005 =>67.00
68.005 =>68.00
69.005 =>69.00
from 64 on all numbers are rounded down like floor()

-- 
Edit bug report at https://bugs.php.net/bug.php?id=61787&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=61787&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=61787&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=61787&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=61787&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=61787&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=61787&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=61787&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=61787&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=61787&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=61787&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=61787&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=61787&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=61787&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=61787&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=61787&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=61787&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=61787&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=61787&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=61787&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=61787&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=61787&r=mysqlcfg

Reply via email to