Req #33988 [Opn->Wfx]: Locales - convert a string to float
Edit report at https://bugs.php.net/bug.php?id=33988&edit=1
ID: 33988
Updated by: yohgaki@php.net
Reported by: tpc at klub dot chip dot pl
Summary: Locales - convert a string to float
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
-Package: Feature/Change Request
+Package: *General Issues
Operating System: Linux / Windows
PHP Version: 4.3.11
Block user comment: N
Private report: N
New Comment:
PHP would not support locale depended number formats in arthritics.
Previous Comments:
------------------------------------------------------------------------
[2005-08-03 22:53:13] tpc at klub dot chip dot pl
Description:
------------
When I use locales and convert a string to float,
I get a truncated value, eg:
// comma as a decimal separator
setlocale(LC_ALL,'pl_PL');
$b = "1,2";
$c = $b*2;
echo $c; // php 4.2 >>> 2,4
// php >= 4.3 >>> 2 (without any warning)
In php 4.2 (5.x) you used a strtod function. Now you use our zend_strtod
function which ignores locales. This truncating
should be reported as a warning.
My suggest is:
Zend/zend_strtod.c, line: 1290:
if (c == ',') zend_error(E_WARNING, "Convert string to double: wrong decimal point,
only . (truncate number %s)", s00);
Thanks in advance for adding this feature in the new version.
Expected result:
----------------
Loging warning or notice if lose precision.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=33988&edit=1
Thread (2 messages)