ID:               49817
 User updated by:  wojtech at sam-germany dot de
 Reported By:      wojtech at sam-germany dot de
 Status:           Bogus
 Bug Type:         Math related
 Operating System: Windows XP SP2
 PHP Version:      5.2SVN-2009-10-09 (snap)
 New Comment:

If you think, that I hadn't seen the note, you are wrong.
I can read:
"Note:  PHP doesn't handle strings like "12,300.2" correctly by
default. See converting from strings."
(I still had said "the problem is known".)

But could you explain me the reason of the behaviour? 
Why don't change it to what everyone would expect?
Or I think so wrongly?


Previous Comments:
------------------------------------------------------------------------

[2009-10-09 08:43:53] [email protected]

http://de3.php.net/round

------------------------------------------------------------------------

[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

Reply via email to