|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17105 floating point numbers truncated due to locale
Submitted: 2002-05-08 18:42 UTC Modified: 2002-10-10 11:53 UTC
Avg. Score:5.0 ± 0.0
Reproduced:7 of 8 (87.5%)
Same Version:1 (14.3%)
Same OS:5 (71.4%)
From: acm at tweakers dot net Assigned: hholzgra (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 4.2.0 OS: multiple linux versions
Private report: No CVE-ID: None
 [2002-05-08 18:42 UTC] acm at tweakers dot net
Using the code below results into truncation of the floating point numbers if the code is included after the setlocale call.

I saw some old reports of this problem, but the developers claimt to have fixed this.

Tested it on 3 servers, one running php4.2.0 with apache 1.3.24 on gentoo linux 1.1a, the second using apache-1.3.24 with php4.1.2 on redhat 7.1 and the third running apache-1.3.24 with php4.1.2 on slackware 7.
$test = new class1();

$test = new class1();
$test = new class2();

class class1
    function class1()
        $float = 1.1;
$float = 1.1;

class class2
    function class2()
        $float = 1.1;
$float = 1.1;

If you need any extra information, I'll supply you with that :)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-17 08:50 UTC]
yet another setlocale() related issue :(
 [2002-06-23 13:57 UTC] ludovic dot langeNOSPAM at free dot fr
Same problem with version 4.2.1

Setting the LC_NUMERIC locale category is enough to trigger (or workaround) the bug :

Workaround :

$locale = setlocale( LC_NUMERIC, 0 );
setlocale( LC_NUMERIC, "C" );
// include / include_once / require / require_once...
setlocale( LC_NUMERIC, $locale );
unset( $locale );
 [2002-10-10 11:53 UTC]
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at
In case this was a documentation problem, the fix will show up soon at

In case this was a website problem, the change will show
up on the site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Sep 20 09:03:36 2021 UTC