comp.lang.ada
 help / color / mirror / Atom feed
* Re: integer'image
@ 1991-01-28  3:27 Jim West (Stealth Contractor)
  1991-01-28 15:04 ` integer'image Michael Feldman
  0 siblings, 1 reply; 23+ messages in thread
From: Jim West (Stealth Contractor) @ 1991-01-28  3:27 UTC (permalink / raw)



In article <2563@sparko.gwu.edu>,
mfeldman@seas.gwu.edu (Michael Feldman) writes...

>In answering the question about cursor control, George Harrison and I used
>2 different techniques to get the row and column values sent to the 
>terminal. I assumed an Integer_IO instantiation; he (probably rightly) did
>not. But all this makes me wonder why on earth Integer'Image should
>decide to prepend a blank to the numeric string. To delete this blank,
>just to get a left-adjusted numeric string, requires overkill code of
>one kind or another, as George's solution makes abdundantly clear.
> 
>The Put operations for integers, enumerations, etc., allow you to control
>the field width exactly; you can right-adjust or you can display the literal
>flush-left. Why should the attribute not do the same? I HATE these stupid
>little counterintuitive surprises in Ada, much as I like the language in
>general. Drives students absolutely up the wall.
> 
>The Ada9x Requirements do not give any specifics in the "little things
>to clean up" category, but I surely hope the Mapping/Revision team will
>give some attention to making the whole attribute system more uniform and
>intuitive. I can give examples if anyone would like. 
>Any response from anyone on the team?
> 

  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.

  The following program and output demonstrates this.


with
	text_io,
	integer_text_io; -- preinstanciation of text_io.integer_io(integer)

procedure INT_TEST is

  x : integer := 3;
  y : integer := -5;

begin --INT_TEST

  text_io.put_line ("Here is the test...");
  text_io.put_line ("->" & integer'image(x) & "<-");
  text_io.put_line ("->" & integer'image(y) & "<-");

end INT_TEST;


Here is the test...
-> 3<-
->-5<-

  I don't disagree with you when it comes to just positive numbers and you
wish to display them without this leading blank.

----------------------------------------------------------------------
 Jim West                      |  The Schainker Converse
 west@widgit.enet.dec.com      |  to Hoare's Law :
                               |
 These are my opinions.        |   Inside every small problem
 Digital has no idea           |     is a larger problem struggling
 what I'm  saying.             |       to get out.
----------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 23+ messages in thread
* integer'image
@ 2000-04-17  0:00 NANCY HEHIR
  2000-04-17  0:00 ` integer'image Ted Dennison
                   ` (2 more replies)
  0 siblings, 3 replies; 23+ messages in thread
From: NANCY HEHIR @ 2000-04-17  0:00 UTC (permalink / raw)


When I run the following code

integer_string:string(1..2);
.
.
.
for x in 1..20 loop

    integer_string:=integer'image(x);
end loop;

everything is fine until x=10. This raises a constraint error which I
interpret to be a problem with mismatched string lenghts. If I increase
integer_string lenght a constraint error is raised on the first iteration.
have tried declaring integer_string as unbounded but integer'image returns a
standard string.

I'm sure that it is a standard application to convert integers to their
string images but I can't figure what I'm missing here.






^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2000-04-19  0:00 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [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
1991-01-28  3:27 integer'image Jim West (Stealth Contractor)
1991-01-28 15:04 ` integer'image Michael Feldman
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

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