Bug #73732 [NEW]: Sprintf bug for 1.15*100*2^n values

From: Date: Tue, 13 Dec 2016 10:25:03 +0000
Subject: Bug #73732 [NEW]: Sprintf bug for 1.15*100*2^n values
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-205954@lists.php.net to get a copy of this message
From: teodor dot danciu at gmail dot com Operating system: Irrelevant PHP version: Irrelevant Package: Strings related Bug Type: Bug Bug description:Sprintf bug for 1.15*100*2^n values Description: ------------ sprintf("%03d ",(1.15*100)); and values multiplied by 2 return wrong values ex 114 instead of 115 Test script: --------------- $price=1.15*100; echo sprintf("%03d ",$price); // prints 114 instead of 115 $price=1.15*100*2; echo sprintf("%03d ",$price); // prints 229 instead of 230 $price=1.15*100*4; echo sprintf("%03d ",$price); // prints 459 instead of 460 $price=1.15*100*8; echo sprintf("%03d ",$price); // prints 919 instead of 920 $price=1.15*100*10; echo sprintf("%03d ",$price); // prints 1149 instead of 1150 -- Edit bug report at https://bugs.php.net/bug.php?id=73732&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73732&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73732&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73732&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=73732&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=73732&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=73732&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=73732&r=needscript Try newer version: https://bugs.php.net/fix.php?id=73732&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=73732&r=support Expected behavior: https://bugs.php.net/fix.php?id=73732&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=73732&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=73732&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=73732&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73732&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=73732&r=dst IIS Stability: https://bugs.php.net/fix.php?id=73732&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=73732&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=73732&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=73732&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=73732&r=mysqlcfg

« previous php.bugs (#205954) next »