From:             wojtech at sam-germany dot de
Operating system: Windows XP SP2
PHP version:      5.2SVN-2009-10-09 (snap)
PHP Bug Type:     Math related
Bug description:  round() couldn't handle german floats with comma

Description:
------------
The problem is known, but the result can't be the last answer.
I must calculate the body mass index for my company.
Yesterday I registered rounding errors between 0.1 and 0.3.
The problem: german doctors declares weight as "63,3" and not as "63.3".
It was my fault trusting in PHPs typecasting.
BUT: why trying typecasting a stupid string, so round() gives a "correct"
answer?
I except returning FALSE, if the given parameter contains something else
than "0-9" and ".".

Reproduce code:
---------------
$var = "German doctors don't know the point.";
print round($var, 1);
$var = "3 german doctors dont't know the point.";
print round($var, 1);
$var = "3,467";
print round($var, 1);
$var = "3.465";
print round($var, 1);

Expected result:
----------------
FALSE
FALSE
FALSE
3,5

Actual result:
--------------
0
3
3
3.5

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

Reply via email to