php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49254 setlocale affects math functions
Submitted: 2009-08-14 14:49 UTC Modified: 2009-08-18 08:14 UTC
From: stakadush at yahoo dot com Assigned:
Status: Not a bug Package: Math related
PHP Version: 5.3.0 OS: Ubuntu 9.04 & OS X 10.5.7
Private report: No CVE-ID: None
 [2009-08-14 14:49 UTC] stakadush at yahoo dot com
Description:
------------
setlocalte affects the return of math functions, making them unusable.
in this example the dot is being replaced with the italian comma 
notation.

Reproduce code:
---------------
setlocale(LC_ALL, 'it_IT.UTF-8');

echo abs(-5.5);

Expected result:
----------------
5.5

Actual result:
--------------
5,5

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-17 09:40 UTC] jani@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php


 [2009-08-18 08:14 UTC] stakadush at yahoo dot com
hey

this was not the case in 5.2 (i've verified with latest 5.2.10), and the documentation doesn't say 
anything about this either. actually, for the function from the example (abs) it says the return 
value will be either integer or float - but a string is being returned.

also in the setlocale documentation there's no mentioning of this behavior, or a behavior change 
from 5.2.

setlocale should (and until 5.2 did) affect only functions which are used for display, such as 
number_format - where you'd expect this.

anyway, how helpful is it when you need to do calculations? it's only useful for display purposes. 

please recheck/reconsider.
thanks. :)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 01 13:01:31 2024 UTC