#25864 [Com]: sprintf error

From: Date: Tue, 14 Oct 2003 14:01:43 +0000
Subject: #25864 [Com]: sprintf error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-48974@lists.php.net to get a copy of this message
ID: 25864 Comment by: tony2001 at phpclub dot net Reported By: heppevonhambach at web dot de Status: Open Bug Type: Unknown/Other Function Operating System: linux PHP Version: Irrelevant New Comment: 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 Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#48974) next »