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.8 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!usc!apple!olivea!decwrl!pa.dec.com!shodha.enet.dec.com!widgit.enet.dec.com!west From: west@widgit.enet.dec.com (Jim West (Stealth Contractor)) Newsgroups: comp.lang.ada Subject: Re: integer'image Message-ID: <2390@shodha.enet.dec.com> Date: 28 Jan 91 03:27:31 GMT Sender: news@shodha.enet.dec.com Organization: Digital Equipment Corporation List-Id: 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. ----------------------------------------------------------------------