#25864 [Opn->Bgs]: sprintf error
| From: | tony2001@php.net | Date: | Tue, 14 Oct 2003 14:04:00 +0000 |
| Subject: | #25864 [Opn->Bgs]: sprintf error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-48975@lists.php.net to get a copy of this message | ||
ID: 25864
Updated by: tony2001@php.net
Reported By: heppevonhambach at web dot de
-Status: Open
+Status: Bogus
Bug Type: Unknown/Other Function
Operating System: linux
PHP Version: Irrelevant
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Previous Comments:
------------------------------------------------------------------------
[2003-10-14 10:01:43] tony2001 at phpclub dot net
pay attention:
var_dump($n); will output float(1234567890120).
i.e. your integer were automagically converted to float.
so you need to use:
$s = sprintf( "%0{$nL}.0f",$n );
to get expected result.
look here for more info:
http://www.php.net/manual/en/language.types.integer.php
------------------------------------------------------------------------
[2003-10-14 09:14:13] heppevonhambach at web dot de
Description:
------------
looks like sprintf has problems with big numbers
Reproduce code:
---------------
$n = 1234567890123;
$nL = 17;
$s = sprintf( "%0{$nL}d",$n );
Expected result:
----------------
00001234567890123
Actual result:
--------------
00000001912276171
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25864&edit=1