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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 101deb,495b037244521cf3 X-Google-Attributes: gid101deb,public X-Google-Thread: 103376,22b2c05a8088bbb2 X-Google-Attributes: gid103376,public From: rav@goanna.cs.rmit.edu.au (robin) Subject: Re: Leading zeros with Int_IO.Put()? Or another package? Date: 1996/11/13 Message-ID: <56bi13$3pa$1@goanna.cs.rmit.edu.au>#1/1 X-Deja-AN: 196133531 expires: 10 February 1997 00:00:00 GMT references: <327FB8A3.745B@itg-sepg.logicon.com> <55ubsh$lh0$1@goanna.cs.rmit.edu.au> organization: Comp Sci, RMIT, Melbourne, Australia newsgroups: comp.lang.ada,comp.lang.pl1 nntp-posting-user: rav Date: 1996-11-13T00:00:00+00:00 List-Id: dewar@merv.cs.nyu.edu (Robert Dewar) writes: >>robin says >>"Interface to PL/I and you can use standard I/O: >>put edit (n) (P'-99999999'); >>and you don't have to worry about whether the number is >>negative either. The nines in the picture format >>force leading zeros to print. >>And if you want, you can insert commas in the output >>to make it more readable. The picture specification becomes: >>P'-999,999,999'" >If you want to use picture editing to solve this kind of problem, then >use the picture editing in Ada, no need to wander off into PL/1, even in >the unlikely case that you have a PL/1 compiler at hand. Personally I >dislike the picture stuff in PL/1, they tried to improve on COBOL and >made a mess of it. PL/I picture editing is a lot simpler than using Ada's, which -- if implemented by the compiler -- applies to decimal types. For *any* data type -- binary integer, decimal integer, float, complex, etc, PL/I has full picture editing. It's ony necessary to use a simple line such as: put edit (n) (P'-99999999'); or, for the real mccoy, put edit (d) (P'999.V999'); [d is decimal fixed with fraction, or floating-point, PICTURE, etc] which is a lot less than the (up to) 82 lines of Ada code suggested by various posters to force zeros to print. --------------------------------------------------------------------------- -- Utility to print zero-filled strings of integer values. --------------------------------------------------------------------------- package zero_fill is .....[81 lines of Ada deleted]