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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 03:01:29 2024 UTC