comp.lang.ada
 help / color / mirror / Atom feed
From: mfeldman@seas.gwu.edu (Michael Feldman)
Subject: Re: integer'image
Date: 28 Jan 91 15:04:57 GMT	[thread overview]
Message-ID: <2638@sparko.gwu.edu> (raw)
In-Reply-To: 2390@shodha.enet.dec.com

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

  reply	other threads:[~1991-01-28 15:04 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1991-01-28  3:27 integer'image Jim West (Stealth Contractor)
1991-01-28 15:04 ` Michael Feldman [this message]
1991-01-28 23:09   ` integer'image (George C. Harrison) Norfolk State University
1991-01-29 19:55     ` integer'image stephen edwards
  -- strict thread matches above, loose matches on Subject: below --
2000-04-17  0:00 integer'image NANCY HEHIR
2000-04-17  0:00 ` integer'image Ted Dennison
2000-04-18  0:00   ` integer'image Marin D. Condic
2000-04-18  0:00     ` integer'image Ted Dennison
2000-04-18  0:00       ` integer'image Marin D. Condic
2000-04-17  0:00 ` integer'image tmoran
2000-04-19  0:00 ` integer'image MaggieJohn
     [not found] <2563@sparko.gwu.edu>
1991-01-18 19:13 ` integer'image Arthur Evans
1991-01-18 20:32   ` integer'image Michael Feldman
1991-01-20  2:54   ` integer'image       Hoysch
1991-01-20 23:10     ` integer'image Michael Feldman
1991-01-21 15:23     ` integer'image Jerry Callen
1991-01-21 19:41       ` integer'image Steven V. Case
1991-01-21 21:54         ` integer'image Jerry Callen
1991-01-22 19:21         ` integer'image Michael Feldman
1991-01-22 21:37           ` integer'image Richard Pattis
1991-01-23 16:29             ` integer'image Michael Feldman
1991-01-18 23:05 ` integer'image (George C. Harrison) Norfolk State University
1991-01-19 10:51 ` integer'image Jean Pierre Rosen
replies disabled

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