Bug #17079 [Com]: setlocale changes the internal representation of floats
| From: | lildurk17079 at gmail dot com | Date: | Wed, 01 Sep 2021 18:43:44 +0000 |
| Subject: | Bug #17079 [Com]: setlocale changes the internal representation of floats | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-236277@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=17079&edit=1
ID: 17079
Comment by: lildurk17079 at gmail dot com
Reported by: jonathan at tricolon dot com
Summary: setlocale changes the internal representation of
floats
Status: Not a bug
Type: Bug
Package: Scripting Engine problem
Operating System: Red Hat Linux 7.1
PHP Version: 4.3.0 RC2
Assigned To: hholzgra
Block user comment: N
Private report: N
New Comment:
Lil Durk is a private agency dedicated to providing responsible access to legal cannabis for adults
aged 19 and older. Weâre an exclusively online retailer and wholesaler for recreational
cannabis and a trusted source for information about cannabis and cannabis-related issues. We believe
our work is meaningful and we take pride in our mandate to promote the socially responsible use of
legal cannabis. https://lildurk.com/
Previous Comments:
------------------------------------------------------------------------
[2013-07-31 09:41:00] philonor at googlemail dot com
Did the behavior change between 5.3 and 5.4?
I get curious values running the following script on
5.3.3 (ubuntu) and 5.4.7 (win):
<?php
setlocale(LC_ALL, 'en_EN');
$x = 0.1;
echo $x;
echo '<br />';
setlocale(LC_ALL, 'de_DE');
$x = 0.1;
echo $x;
?>
5.3.3 (ubuntu) gives me the following:
0.1
0,1
5.4.7 (win):
0.1
0.1
That can't be the expected behavior if there was no change
between those versions?
------------------------------------------------------------------------
[2012-06-22 11:05:53] schindler dot andor at empo dot deletethis dot hu
Yes, this is not a bug. This is a huge epic fail. This is a great example, why people hate PHP.
------------------------------------------------------------------------
[2004-10-23 16:58:47] erki at lap dot ttu dot ee
Having the setlocale function in string.c execute
if ((lc.decimal_point)[0] != '.') {
/* set locale back to C */
setlocale(LC_NUMERIC, "C");
}
is not a solution. The particular "fix" broke other things. In many countries, comma is
used as a decimal separator. Case in point: 3 weeks ago, a certain financial database of a major
telco company in Europe was upgraded to use PHP 4.3.8 (formerly 4.2.2). The system uses Oracle for
persistence, where the decimal separator is a comma, as is a custom in that country. So numbers came
in from Oracle, and then PHP was unable to process them correctly. For example, if a client had a
debt of 25,12?, and the client paid 5?, then the comparison ($paid_amount > $debt) said
incorrectly that the paid amount was more than the debt.
Result: hundreds of wasted man-hours. In the end we recompiled PHP without that "fix".
------------------------------------------------------------------------
[2003-07-05 06:13:19] dMNz at one dot lt
am pabandymuj..
------------------------------------------------------------------------
[2003-03-24 10:18:13] moriyoshi@php.net
Related discussion: http://news.php.net/article.php?group=php.dev&article=95211
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=17079
--
Edit this bug report at https://bugs.php.net/bug.php?id=17079&edit=1