From: bobson at rpg dot pl
Operating system: Linux
PHP version: 5CVS-2006-10-11 (snap)
PHP Bug Type: Unknown/Other Function
Bug description: String->float->String conversion behavior
Description:
------------
When converting to float from string, its always use "." as a decimal
separator, but echo shows decimal separator using locale definition.
Because of that there's a problem eg. in dbase function on numeric(float)
fields.
Reproduce code:
---------------
setlocale(LC_ALL,"pl_PL");
echo '1.2*1=';
echo "1.2"*1;
//produce 1.2*1=1,2
echo '1,2*1=';
echo "1,2"*1;
//produce 1,2*1=1 <- this was expected to produce 1,2 float on pl_PL (in
PL decimal separator is ",")
setlocale(LC_ALL,"en_EN");
echo '1.2*1=';
echo "1.2"*1;
//produce 1.2*1=1.2
echo '1,2*1=';
echo "1,2"*1;
//produce 1,2*1=1 <- correct on en_EN
//the most ugly examlpe
setlocale(LC_ALL,"pl_PL");
echo (("1.2"*1)."")*1; //produce 1
echo (("1,2"*1)."")*1; //also produce 1
Expected result:
----------------
on pl_PL
1
1,2
on en_EN
1.2
1
last one example code:
1
1,2
Actual result:
--------------
on pl_PL
1,2
1
on en_EN
1.2
1
last one example code:
1
1
--
Edit bug report at http://bugs.php.net/?id=39126&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=39126&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=39126&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=39126&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=39126&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=39126&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=39126&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=39126&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=39126&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=39126&r=support
Expected behavior: http://bugs.php.net/fix.php?id=39126&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=39126&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=39126&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=39126&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39126&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=39126&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=39126&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=39126&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=39126&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=39126&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=39126&r=mysqlcfg