Bug #69578 [NEW]: sprintf missing g-format

From: Date: Wed, 06 May 2015 00:04:36 +0000
Subject: Bug #69578 [NEW]: sprintf missing g-format
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-192505@lists.php.net to get a copy of this message
From: dlai7 at bigbiz dot com Operating system: Linux PHP version: 5.4.40 Package: Unknown/Other Function Bug Type: Bug Bug description:sprintf missing g-format Description: ------------ Running the test script below tries to format a number using %d %e $f and %g formats in sprintf However the output is blank for %g format It appears %g isn't supported Output: 15.5 d value is 15 15.5 e value is 1.55000e+1 15.5 f value is 15.500000 15.5 g value is 0.5 d value is 0 0.5 e value is 5.00000e-1 0.5 f value is 0.500000 0.5 g value is 155 d value is 155 155 e value is 1.55000e+2 155 f value is 155.000000 155 g value is Test script: --------------- <?php echo "15.5 d value is ",sprintf('%d',15.5),"\n"; echo "15.5 e value is ",sprintf('%e',15.5),"\n"; echo "15.5 f value is ",sprintf('%f',15.5),"\n"; echo "15.5 g value is ",sprintf('%g',15.5),"\n"; echo "0.5 d value is ",sprintf('%d',0.5),"\n"; echo "0.5 e value is ",sprintf('%e',0.5),"\n"; echo "0.5 f value is ",sprintf('%f',0.5),"\n"; echo "0.5 g value is ",sprintf('%g',0.5),"\n"; echo "155 d value is ",sprintf('%d',155),"\n"; echo "155 e value is ",sprintf('%e',155),"\n"; echo "155 f value is ",sprintf('%f',155),"\n"; echo "155 g value is ",sprintf('%g',155),"\n"; ?> Expected result: ---------------- Expecting %g format to output similar to the C sprintf function example: 15.5 g value is 15.5 0.5 g value is 0.5 155 g value is 155 -- Edit bug report at https://bugs.php.net/bug.php?id=69578&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69578&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69578&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69578&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=69578&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=69578&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=69578&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=69578&r=needscript Try newer version: https://bugs.php.net/fix.php?id=69578&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=69578&r=support Expected behavior: https://bugs.php.net/fix.php?id=69578&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=69578&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=69578&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=69578&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69578&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=69578&r=dst IIS Stability: https://bugs.php.net/fix.php?id=69578&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=69578&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=69578&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=69578&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=69578&r=mysqlcfg

« previous php.bugs (#192505) next »