Bug #583 Updated: sprintf not allowing zero padding on decimal numbers
| From: | Bug Database | Date: | Thu, 10 Sep 1998 21:50:03 +0000 |
| Subject: | Bug #583 Updated: sprintf not allowing zero padding on decimal numbers | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-926@lists.php.net to get a copy of this message | ||
ID: 583
Updated by: zeev
Reported By: stef@moi.org
Status: Closed
Bug Type: Misbehaving function
Assigned To:
Comments:
[jim]
Unfortunately, supporting %.# for decimal numbers isn't
quite trivial -- for example, sprintf("%3.2d", 8) produces
" 08". (Not that this can't or shouldn't be supported,
just making note of the fact that it isn't trivial and
requires handling cases like that.)
[ssb]
PHP's formatter is a bit different from that of libc here.
Everything after the "." in the formatting specifier
applies to the decimal part of a floating-point number,
(or the truncation length for strings). Won't
sprintf("%02d", $foo) do what you want, or have I
misunderstood your problem?
[zeev]
this has been lingering for too long, Stig's solution works perfectly.
Full Bug description available at: http://ca.php.net/bugs.php3?id=583
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net