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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,948c8b1c8730d81 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-13 18:46:37 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!elnk-pas-nf2!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!stamper.news.atl.earthlink.net!harp.news.atl.earthlink.net!not-for-mail From: Richard Riehle Newsgroups: comp.lang.ada Subject: Re: ATOI Date: Sun, 13 Jul 2003 18:49:57 -0700 Organization: AdaWorks Software Engineering Message-ID: <3F120C45.B85D86D9@adaworks.com> References: <3F0F6B08.9050200@attbi.com> Reply-To: richard@adaworks.com NNTP-Posting-Host: 3f.bb.a0.d5 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Server-Date: 14 Jul 2003 01:48:23 GMT X-Mailer: Mozilla 4.7 [en] (Win98; I) X-Accept-Language: en Xref: archiver1.google.com comp.lang.ada:40248 Date: 2003-07-14T01:48:23+00:00 List-Id: "Robert I. Eachus" wrote: > Riccardo Fulcoli wrote: > > > > i.e. I'm looking for a function like the C "atoi". > > > Why would you want to do an Unchecked_Conversion. See Ada.Text_IO, or > Ada.Integer_Text_IO. But if you have already read in a string you can > use the attribute function Integer'Value(Some_String). Note that the > function will ignore leading and trailing spaces, but otherwise can > raise an exception which may not be what you want. See RM 3.5(52) I recall a similar problem from a former client when someone decided they had a need to convert the floating point of a VAX to the floating point of a different mainframe. A programmer was assigned to write the algorithm to make this happen. Those of you who know the VAX will recall that the sign bit is in an unusual location. The programmer was going nuts trying to write this program until he was advised that Text_IO.Float_IO (in Ada 83) already had a conversion routine that would allow him to convert the floating point to scientific notation, write it to tape, and read it with Text_IO.Float_IO on the target machine. We so often do things the hard way when the utilities are right there waiting to be used. Richard Riehle