From:             cu19 at gmx dot de
Operating system: WinXP SP3
PHP version:      5.3CVS-2009-02-17 (CVS)
PHP Bug Type:     *Math Functions
Bug description:  number_format misbehaving with some values

Description:
------------
In my script im using number_format to format values read from a MSSQL-DB
via ODBC. Works fine, as long as the value is not equal to 1.9, 2.9, 3.9,
1.7 and probably some others.

I've made the following test script:
<?php
echo number_format(3.9, 2);
?>

Output is expected to be 3.90, but in fact is 9.8:
I don't know where this colon does come from, but for me it seems to be an
error in number_format. Using sprintf('%4.2f', 3.9) leads to the same
problem.

I'm using PHP 5.2.8 on Apache 2.2.9 on Windows XP MCE SP3. When Apache
just got restarted, the test script works fine, but when executing my
(quite large) script with several ODBC queries, it produces this error and
after execution also the test script fails.

I've tried using 5.3 snapshot and 5.2.8 snap, the error occurs also. With
PHP 5.2.6, the error didn't occur as far as I can remember. The error
doesn't occur, too, with CLI.

Any idea? Or is it about the Apache webserver?

Reproduce code:
---------------
echo number_format(3.9, 2);

Expected result:
----------------
3.90

Actual result:
--------------
3.8:

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

Reply via email to