From:             arnarb at oddi dot is
Operating system: Linux 2.4.18
PHP version:      4.3.2
PHP Bug Type:     Scripting Engine problem
Bug description:  Using locale with , as decimal sep., floats truncated on conversion 
from string

Description:
------------
When strings containing numbers in the locale format, and the locale uses
, as the decimal seperator, converting the string to a float cuts off at
the , and returns the integer part.

This was addressed in bugs #17105, #17815 and others. Those reports were
closed and the problem was claimed to be fixed in CVS as of November 2002
by iliaa and sniper.

This bug is however still present in 4.3.2, as the reproduce code
demonstrates.

A quick look indicated that libc's strtod was being used for the
conversion, I verified that it is working on my platform.

Reproduce code:
---------------
<?php
printf("%.3f\n", 3.233);
print sprintf("%.3f", 3.233)+1;
print "\n";

setlocale(LC_ALL, "is_IS");

printf("%.3f\n", 3.233);
print sprintf("%.3f", 3.233)+1;
print "\n";
?>

Expected result:
----------------
3.233
4.233
3,233
4,233

Actual result:
--------------
3.233
4.233
3,233
4

-- 
Edit bug report at http://bugs.php.net/?id=24591&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=24591&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=24591&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=24591&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=24591&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=24591&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=24591&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=24591&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=24591&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=24591&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=24591&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=24591&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24591&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=24591&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=24591&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=24591&r=gnused

Reply via email to