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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c8a853b515609781 X-Google-Attributes: gid103376,public From: Richard D Riehle Subject: Re: strings to floats/integers Date: 1998/08/26 Message-ID: <6s1e9k$bgq@sjx-ixn5.ix.netcom.com>#1/1 X-Deja-AN: 384965881 References: <35e41033.9324314@200.223.0.87> Organization: ICGNetcom X-NETCOM-Date: Wed Aug 26 9:48:52 AM PDT 1998 Newsgroups: comp.lang.ada Date: 1998-08-26T09:48:52-07:00 List-Id: In article <35e41033.9324314@200.223.0.87>, joke@haha.com (Mr Pinga) wrote: >can anyone tell me how to convert a string to a float and/or integer?? > >i need to go from the form mystring := "123.4567" to the form myfloat >:= 123.4567 > >or mystring := "12345" to myinteger := 12345 > >please, I am getting quite desperate. I have looked all through the >ADA95 reference manual, and looked all over the WWW but i cant find >anything. The closest i have found is Unchecked_Conversion but it >converts things to gibberish so mystring := "3" becomes myfloat := >0.0E000 etc etc The conversion between strings and float and strings and integers can easily be accomplished using Ada.Text_IO. Note that for Ada.Text_IO.Integer_IO and Ada.Text_IO.Float_IO there are Get and Put operations defined for conversion between strings and the desired numeric type. Not only is this easy, it is also more portable than some alternatives. For some odd reason, this feature of Ada.Text_IO is frequently undiscovered, even by programmers who have been using Ada for many years. Richard Riehle richard@adaworks.com http://www.adaworks.com