From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,22b2c05a8088bbb2 X-Google-Attributes: gid103376,public From: "Norman H. Cohen" Subject: Re: Leading zeros with Int_IO.Put()? Or another package? Date: 1996/11/08 Message-ID: <32834C9C.6D6A@watson.ibm.com>#1/1 X-Deja-AN: 195294962 references: <3281088B.24F@watson.ibm.com> content-type: text/plain; charset=us-ascii organization: IBM Thomas J. Watson Research Center mime-version: 1.0 reply-to: ncohen@watson.ibm.com newsgroups: comp.lang.ada x-mailer: Mozilla 3.0 (Win95; I) Date: 1996-11-08T00:00:00+00:00 List-Id: I wrote: > Using the GNAT-specific 'Img attribute and the standard package > Ada.Strings.Fixed: [example presuming that X'Img = "99" when X=99 deleted] > Using the standard 'Image attribute (which annoyingly places a space in > front of nonnegative numerals) instead of 'Img to retain portability to > other compilers: > > declare Image : constant String := Integer'Image(Minute); -- Pascal Obry's correction > Buffer : String (1 .. Field_Length); -- 2 in the case of minutes > begin > Ada.Strings.Fixed.Move > (Source => Image (2 .. Image'Length), > Target => Buffer, > Justify => Right, > Pad => '0'); > Ada.Text_IO.Put (Buffer); > end; Keith Thompson informed me in private correspondence that, like the standard 'Image attribute, the GNAT-only 'Img attribute puts in that annoying leading space, and upon trying it I find he's right. That's the risk of relying on vague recollections of descriptions of 'Img by GNAT team members rather than testing its behavior. (The ideal approach, of course, is to consult the documentation, but no version of gnatinfo.txt that I have mentions 'Img.) Anyway, the bottom line is that you have to deal with the annoying space anyway, so you might as well use the standard 'Image attribute. -- Norman H. Cohen mailto:ncohen@watson.ibm.com http://www.research.ibm.com/people/n/ncohen