home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / perl / 5704 < prev    next >
Encoding:
Text File  |  1992-09-03  |  1.0 KB  |  29 lines

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