Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: Bob Harris <harris@zk3.dec.com>
To: wallace.liu@cwo.com.au
Subject: Re: No subject was specified.
Date: 1999/09/21	[thread overview]
Message-ID: <210919991020459164%harris@zk3.dec.com> (raw)
In-Reply-To: 37E705E1.D1303F3A@cwo.com.au

[[ 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
<wallace.liu@cwo.com.au> 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.



  parent reply	other threads:[~1999-09-21  4:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-09-21  4:00 No subject was specified Wallace Liu
1999-09-21  4:00 ` Pit Linnartz
1999-09-21  4:00 ` Bob Harris [this message]
1999-09-22  4:00 ` Wallace Liu
1999-09-26  4:00   ` Claus Divossen
  -- strict thread matches above, loose matches on Subject: below --
1999-09-07  4:00 Wallace Liu
1999-09-07  4:00 ` Stuart R. Fuller
1999-01-28  5:00 Joseph H. Lee
1998-11-05  5:00 Joseph H. Lee
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox