#8097 [Fbk->NoF]: printf() and float data vs.setlocale()
| From: | php-bugs at lists dot php dot net | Date: | Fri, 08 Nov 2002 07:00:06 +0000 |
| Subject: | #8097 [Fbk->NoF]: printf() and float data vs.setlocale() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-24323@lists.php.net to get a copy of this message | ||
ID: 8097
Updated by: php-bugs@lists.php.net
Reported By: hh@loca.net
-Status: Feedback
+Status: No Feedback
Bug Type: Strings related
Operating System: Linux (SuSE 7.0)
PHP Version: 4.0.3pl1
New Comment:
No feedback was provided for this bug for over 2 weeks, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
Previous Comments:
------------------------------------------------------------------------
[2002-10-23 07:04:41] hholzgra@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php4-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-latest.zip
------------------------------------------------------------------------
[2002-10-23 06:53:02] kaatz@wwe.biz
This problem also exits in our application which runs on php-4.2.3.
We use 'setlocale' there to handle gettext translations. With LC_ALL
set by 'setlocale' all prices in the shopping basket and VAT
calculations with floats are 'calculated wrong'
Thanks for that hint.
Juergen
------------------------------------------------------------------------
[2001-07-31 16:14:35] andy@php.net
unable to reproduce with latest version of PHP, please
upgrade and re-open if still a problem.
------------------------------------------------------------------------
[2000-12-04 13:08:55] hh@loca.net
Changing the locale setting to a country that uses comma (,)
as the decimal seperator will stip off decimal places from
the float value in printf/sprintf. Example:
MySQL table:
create table test (
name varchar(100),
value float(16,2)
);
insert into test values ('bla', 3.789);
PHP code:
setlocale("LC_ALL", "de_DE");
// mysql_connect etc.
$row = mysql_fetch_array($result);
printf("%s: %.2f",
$row["name"], $row["value"]);
Result:
bla: 3.00
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=8097&edit=1