differences in printf() between php and C

From: Date: Fri, 18 Oct 2002 13:32:03 +0000
Subject: differences in printf() between php and C
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969349167@lists.php.net to get a copy of this message
not sure if anyone has pointed this out, but it would be nice if it was noted in the printf() manpage. in standard C, the format "%10.2f" means show 10 characters, of which the last 3 are decimal point and 2 digits. ie. the total length is 10 chars. in php, it appears that "%10.2f" means show 10 whole number digits, followed by a decimal point and two digits. in C: printf("[10.2f]", 99.99); == [ 99.99] in PHP: printf("[10.2f]", 99.99); == [ 99.99] while i wouldn't expect PHP to "fix" their printf(), this difference should be noted, as it definitely causes C programmers to skew their alignment. -- [ Jim Mercer jim@reptiles.org +1 416 410-5633 ] [ I want to live forever, or die trying. ]

« previous php.doc (#969349167) next »