Bug #28633 [Csd]: sprintf("%3.2f",'1.00') no longer working

From: Date: Sat, 21 Apr 2018 18:56:17 +0000
Subject: Bug #28633 [Csd]: sprintf("%3.2f",'1.00') no longer working
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-214828@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=28633&edit=1

 ID:                 28633
 User updated by:    jschmidt at thriftycmh dot net
 Reported by:        jschmidt at thriftycmh dot net
 Summary:            sprintf("%3.2f",'1.00') no longer working
 Status:             Closed
 Type:               Bug
 Package:            *Mail Related
 Operating System:   Linux 2.4
 PHP Version:        4.3.7
 Assigned To:        iliaa
 Block user comment: N
 Private report:     N

 New Comment:

https://www.delhitrainingcourses.com/learn-ethical-hacking.htm


Previous Comments:
------------------------------------------------------------------------
[2004-07-18 19:29:50] iliaa@php.net

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.



------------------------------------------------------------------------
[2004-07-06 01:33:36] sniper@php.net

Ilia, recheck.. :)


------------------------------------------------------------------------
[2004-06-16 22:36:13] php at alterego dot dp dot ua

Sorry, but this actually is a bug. Kind of brain damage.

echo sprintf('%05.2f', 0.02) . "\n";
00000.02

echo sprintf('%05.2f', 2.02) . "\n";
02.02

Although the double-checked documentation is very uncertain about how this should work, it
definitely should work one of the ways, not both.

------------------------------------------------------------------------
[2004-06-04 22:26:26] jschmidt at thriftycmh dot net

Actually, I did find inconsistency (bug) with the new behavior.

echo sprintf("%06.2f",'1.00');
001.00

echo sprintf("%06.2f",'.01');
000000.01

So which is it?  Pad to 6 characters or pad to 6 on the left of the decimal point?

------------------------------------------------------------------------
[2004-06-04 18:47:23] jschmidt at thriftycmh dot net

OK, looking at /ext/standard formatted_print.c I see what has changed.  Before we were specifying
the desired number of characters to pad to the left of the decimal.  Now we are specifying the total
desired number of characters the output should be padded to.  So technically, we are indeed
"padding the results to the right string size".  Too bad it has been the previous way for
so long.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=28633


--
Edit this bug report at https://bugs.php.net/bug.php?id=28633&edit=1


Thread (10 messages)

« previous php.bugs (#214828) next »