From: hkh at netnords dot dk
Operating system: debian 3.0 - Apache 1.3.26
PHP version: 4.3.7
PHP Bug Type: Strings related
Bug description: Error in output from sprintf()
Description:
------------
I don't get the expected result from sprintf(), when input are less than
[-]1.
Tried the same code on a php 5.0.0b3 (windows), where I got the expected
result.
Maybe its related/oposite to bug #28633
Reproduce code:
---------------
$fmt = "%08.2f";
printf("[".$fmt."]<br />", -10);
printf("[".$fmt."]<br />", -1);
printf("[".$fmt."]<br />", -0.995);
printf("[".$fmt."]<br />", -0.99);
printf("[".$fmt."]<br />", -0.5);
printf("[".$fmt."]<br />", 0);
printf("[".$fmt."]<br />", 0.5);
printf("[".$fmt."]<br />", 0.99);
printf("[".$fmt."]<br />", 0.995);
printf("[".$fmt."]<br />", 1);
printf("[".$fmt."]<br />", 10);
Expected result:
----------------
[-0010.00]
[-0001.00]
[-0001.00] // Not [-0000.99], should't it round down ?
[-0000.99]
[-0000.50]
[00000.00]
[00000.50]
[00000.99]
[00001.00] // Not [00000.99] , should't it round up ?
[00001.00]
[00010.00]
Actual result:
--------------
[-0010.00]
[-0001.00]
[-0000000.99]
[-0000000.99]
[-0000000.50]
[00000000.00]
[00000000.50]
[00000000.99]
[00000000.99]
[00001.00]
[00010.00]
--
Edit bug report at http://bugs.php.net/?id=29185&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29185&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=29185&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=29185&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=29185&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=29185&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=29185&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=29185&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=29185&r=support
Expected behavior: http://bugs.php.net/fix.php?id=29185&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=29185&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=29185&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=29185&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29185&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=29185&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=29185&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=29185&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29185&r=float