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.7 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!seas.gwu.edu!mfeldman From: mfeldman@seas.gwu.edu (Michael Feldman) Newsgroups: comp.lang.ada Subject: Re: integer'image Message-ID: <2638@sparko.gwu.edu> Date: 28 Jan 91 15:04:57 GMT References: <2390@shodha.enet.dec.com> Reply-To: mfeldman@seas.gwu.edu () Organization: The George Washington University, Washington D.C. List-Id: In article <2390@shodha.enet.dec.com> west@widgit.enet.dec.com (Jim West (Stealth Contractor)) writes: > > The blank is for the sign field. Positive numbers are displayed without >the '+' sign whereas negative numbers are displayed with the '-' sign. > > If you were printing numbers that are both positive and negative then >formatting becomes easier with respect to the sign field. > I know I told Rich Pattis I'd stop posting this thread to the net, but I can't let this go by without comment. I know the idea is to get the symmetry with negative numbers. However, it's MUCH easier to prepend the blank if I want it than to strip it off if I don't. Specifically, the string form is nice if you're writing terminal drivers (ANSI control, etc.), which only want to see digits, no spaces. And I'd rather not waste a whole Integer_IO instance just on that, so 'image is the nice way to go. Indeed, I thought that was _just_ was integer'image was intended for! I claim that IF X > 0 THEN Text_IO.Put(' ' & Integer'Image(X); ELSE Text_IO.Put(Integer'Image(X)); END IF; is far easier and cleaner than any of the kludges I've seen to strip the blank. If one wants to avoid burying too many string concatenations (storage allocation problems, it is alleged), then IF X > 0 THEN Text_IO.Put(' '); END IF; Text_IO.Put(Integer'Image(X)); fills the bill and is cleaner still. Compare that with all the junk that's come over the net about how to throw the blank away! I promise to finally shut up on this issue; if Ada9x hasn't gotten the message by now, they never will. Mike