|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-10-14 09:14 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 23:00:01 2025 UTC |
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