|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-07-10 10:52 UTC] arnarb at oddi dot is
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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 14:00:01 2025 UTC |
<?php printf("%.3f\n", 3.233); var_dump(sprintf("%.3f", 3.233) + 1); setlocale(LC_ALL, "is_IS"); printf("%.3f\n", 3.233); var_dump(sprintf("%.3f", 3.233) + 1); ?> Output: 3.233 float(4.233) 3,233 int(4)