php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #33988 Locales - convert a string to float
Submitted: 2005-08-03 22:53 UTC Modified: 2013-08-06 08:33 UTC
From: tpc at klub dot chip dot pl Assigned:
Status: Wont fix Package: *General Issues
PHP Version: 4.3.11 OS: Linux / Windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tpc at klub dot chip dot pl
New email:
PHP Version: OS:

 

 [2005-08-03 22:53 UTC] 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.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-08-06 08:33 UTC] yohgaki@php.net
-Status: Open +Status: Wont fix -Package: Feature/Change Request +Package: *General Issues
 [2013-08-06 08:33 UTC] yohgaki@php.net
PHP would not support locale depended number formats in arthritics.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat May 03 17:01:27 2025 UTC