home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!panther!mothost!merlin.dev.cdx.mot.com!fendahl.dev.cdx.mot.com!mcook
- From: mcook@fendahl.dev.cdx.mot.com (Michael Cook)
- Subject: Re: Very tiny bug in printf? (perl 4.034)
- Message-ID: <mcook.715536130@fendahl.dev.cdx.mot.com>
- Sender: news@merlin.dev.cdx.mot.com (USENET News System)
- Nntp-Posting-Host: fendahl.dev.cdx.mot.com
- Organization: Motorola Codex, Canton, Massachusetts
- References: <1992Sep3.020523.22087@aie.nl>
- Date: Thu, 3 Sep 1992 16:02:10 GMT
- Lines: 16
-
- hansk@aie.nl (Hans Kinwel) writes:
-
- >I expected the following three lines to print out 08 two times.
-
- >$val="8";
- >printf ("%02s\n", $val);
- >printf ("%02d\n", $val);
-
- It probably depends on the underlying implementation of sprintf.
-
- In _Standard C_ by Plauger and Brodie, they say "Following the percent
- character (%), you can write zero or more flags: ... 0 -- to pad a conversion
- with leading zeros after any sign or prefix, in the absence of any other
- padding," which seems to be saying that you should get "08" for both.
-
- Michael.
-