ID: 49817 Updated by: [email protected] Reported By: wojtech at sam-germany dot de -Status: Open +Status: Bogus Bug Type: Math related Operating System: Windows XP SP2 PHP Version: 5.2SVN-2009-10-09 (snap) New Comment:
http://de3.php.net/round Previous Comments: ------------------------------------------------------------------------ [2009-10-09 08:41:17] wojtech at sam-germany dot de 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 this bug report at http://bugs.php.net/?id=49817&edit=1
