From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,2175e42c8841bb13 X-Google-Attributes: gidfee84,public From: Bob Harris Subject: Re: No subject was specified. Date: 1999/09/21 Message-ID: <210919991020459164%harris@zk3.dec.com>#1/1 X-Deja-AN: 527870215 Content-Transfer-Encoding: 8bit References: <37E705E1.D1303F3A@cwo.com.au> To: wallace.liu@cwo.com.au Posted-And-Mailed: yes Content-Type: text/plain; charset=ISO-8859-1 Organization: Digital Equipment Corporation, Palo Alto, CA, USA Mime-Version: 1.0 User-Agent: YA-NewsWatcher/4.2.4 Newsgroups: comp.unix.osf.osf1 [[ This message was both posted and mailed: see the "To," "Cc," and "Newsgroups" headers for details. ]] In article <37E705E1.D1303F3A@cwo.com.au>, Wallace Liu wrote: >I am confused by the output of printf command: > >d=07 >printf "%02d\n" $d >the system print 07; > >d=05 >printf "%02d\n" $d >the system print 05; > >d=09 >printf "%02d\n" $d >the system print this message to me: >printf: 09 not completely converted >00 > >d=08 >printf "%02d\n" $d >the system print this message to me: >printf: 08 not completely converted >00 > >I come cross this problem on Solaris 2.6 and Compaq UNIX. Why printf command >does not complete convert 09 and 08? I am making several assumptions 1) this is peril 2) that the d=08 and d=09 are initially treated as strings. 3) that the printf is converting the strings to numbers. It is my guess that when the strings are being converted, the standard convention, as established in the early days of UNIX and 'C' (maybe even earlier), was that any number beginning with a leading zero was treated as an octal number, and octal numbers only use digits 0-7. The digits 8 and 9 are illegal in octal numbers. If you specify the values as: d=8 d=9 then I think the printf statement would work correctly.