#33644 [NEW]: sprintf digit formating problem

From: Date: Mon, 11 Jul 2005 12:54:16 +0000
Subject: #33644 [NEW]: sprintf digit formating problem
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-81672@lists.php.net to get a copy of this message
From: root at sunstation dot com Operating system: linux PHP version: 4.3.11 PHP Bug Type: Unknown/Other Function Bug description: sprintf digit formating problem Description: ------------ There is a problem with formatting float output for 0.28 values. Check it out. Reproduce code: --------------- <?php for($i=1;$i<=10000;$i++) { $a = round($i/100,2); if (sprintf("%d",$a*100) != $i) echo sprintf("$i -> %d<br>",$a*100); } ?> Expected result: ---------------- I would expect no output at all Actual result: -------------- 29 -> 28 57 -> 56 58 -> 57 113 -> 112 114 -> 113 115 -> 114 116 -> 115 201 -> 200 203 -> 202 205 -> 204 207 -> 206 226 -> 225 228 -> 227 230 -> 229 232 -> 231 251 -> 250 253 -> 252 255 -> 254 402 -> 401 406 -> 405 410 -> 409 414 -> 413 427 -> 426 431 -> 430 435 -> 434 439 -> 438 452 -> 451 456 -> 455 460 -> 459 464 -> 463 477 -> 476 481 -> 480 485 -> 484 489 -> 488 ... ... 8160 -> 8159 8171 -> 8170 8174 -> 8173 8182 -> 8181 8185 -> 8184 -- Edit bug report at http://bugs.php.net/?id=33644&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33644&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33644&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33644&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=33644&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=33644&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=33644&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=33644&r=needscript Try newer version: http://bugs.php.net/fix.php?id=33644&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=33644&r=support Expected behavior: http://bugs.php.net/fix.php?id=33644&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=33644&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=33644&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=33644&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33644&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=33644&r=dst IIS Stability: http://bugs.php.net/fix.php?id=33644&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=33644&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=33644&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=33644&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=33644&r=mysqlcfg

« previous php.bugs (#81672) next »