#40653 [Opn->Bgs]: strval() and floatval() behave differently
| From: | tony2001@php.net | Date: | Tue, 27 Feb 2007 12:27:06 +0000 |
| Subject: | #40653 [Opn->Bgs]: strval() and floatval() behave differently | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-109634@lists.php.net to get a copy of this message | ||
ID: 40653
Updated by: tony2001@php.net
Reported By: plyrvt at mail dot ru
-Status: Open
+Status: Bogus
Bug Type: Strings related
Operating System: Any
PHP Version: 5.2.1
New Comment:
The point is that string representation of doubles (i.e.
double-to-string) always depends on locale settings.
But string-to-double always ignores locale and uses "." as decimal
separator.
That might sound inconsistent, but consider this first:
1) we DO want users to be able to output numbers in locale-dependent
format;
2) we DON'T want scripts to depend on locale or we may end up with
scripts working/not working with particular locales.
Previous Comments:
------------------------------------------------------------------------
[2007-02-27 01:39:51] plyrvt at mail dot ru
Description:
------------
Either strval() or floatval() is buggy. They can respect locale or
ignore locale, but at least both do things the same way!
Reproduce code:
---------------
<?php
setlocale(LC_NUMERIC, "ANY_LOCALE_WITH_,_SEPARATOR");
$f=1.2;
$s=strval($f);
$f=floatval($s);
var_dump($f);
// expected: 1.2 or 1,2
// actual: 1
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40653&edit=1