Xref: utzoo comp.lang.c:15721 comp.sys.ibm.pc:23603 Path: utzoo!attcan!uunet!husc6!uwvax!rutgers!bellcore!faline!thumper!ulysses!andante!alice!ark From: ark@alice.UUCP (Andrew Koenig) Newsgroups: comp.lang.c,comp.sys.ibm.pc Subject: Re: Microsoft C 5.1 question Keywords: Printf formats Message-ID: <8816@alice.UUCP> Date: 22 Jan 89 17:32:40 GMT References: <104@rpi.edu> <198@broadway.UUCP> <6951@june.cs.washington.edu> <7026@june.cs.washington.edu> Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 25 In article <7026@june.cs.washington.edu>, ka@june.cs.washington.edu (Kenneth Almquist) writes: > abcscnge@csuna.UUCP (Scott "The Pseudo-Hacker" Neugroschl) writes: > > In article <6951@june.cs.washington.edu> ka@june.cs.washington.edu (Kenneth Almquist) writes: > > ] printf("%2d:%.2d:%.2d", hour, minute, second); > > > > How about > > printf("%2d:%02d:%02d", hour, minute, second); > > These behave identically. A fair number of years ago, AT&T decided to > switch from the "%02d" format to the "%.2d" format. Actually, they behave identically only for positive numbers. The change came about for several reasons, not all of which I remember. One was a desire to be able to print things like 0x00076552, which just didn't fit into the notion of zero-padding. Another was that `zero-padding' didn't really describe the operation. After all, if you zero-pad -3 to six characters, you should get 0000-3, right? Some head-scratching and a lot of discussion later, we decided that the operation we really wanted was `guarantee at least a particular number of digits' and that that should be done as part of conversion, not as part of padding. -- --Andrew Koenig ark@europa.att.com