#29185 [Opn->Csd]: Error in output from sprintf()
| From: | iliaa@php.net | Date: | Mon, 19 Jul 2004 20:45:01 +0000 |
| Subject: | #29185 [Opn->Csd]: Error in output from sprintf() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-62679@lists.php.net to get a copy of this message | ||
ID: 29185
Updated by: iliaa@php.net
Reported By: hkh at netnords dot dk
-Status: Open
+Status: Closed
Bug Type: Strings related
Operating System: debian 3.0 - Apache 1.3.26
PHP Version: 4.3.7
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2004-07-19 22:33:15] derick@php.net
heh, how is this NOT a bug?
------------------------------------------------------------------------
[2004-07-16 01:31:16] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Both PHP 4 and 5 return the same expected output.
[-0010.00]
[-0001.00]
[-0000000.99]
[-0000000.99]
[-0000000.50]
[00000000.00]
[00000000.50]
[00000000.99]
[00000000.99]
[00001.00]
[00010.00]
------------------------------------------------------------------------
[2004-07-15 15:11:43] hkh at netnords dot dk
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 this bug report at http://bugs.php.net/?id=29185&edit=1