comp.lang.ada
 help / color / mirror / Atom feed
From: anon@anon.org (anon)
Subject: Re: Converting Integer / Float to String
Date: Thu, 17 Jul 2008 08:05:02 GMT
Date: 2008-07-17T08:05:02+00:00	[thread overview]
Message-ID: <O2Dfk.240647$SV4.14072@bgtnsc04-news.ops.worldnet.att.net> (raw)
In-Reply-To: newscache$sc454k$rp5$1@pleione.3soft.de

Another way is to use the "Ada.Float_Text_IO" package. Especially when 
you may normally need the Float_Text_IO package in the program.

Read a integer from a string (buffer) using the "Get" routine:

   procedure Get ( From : in String ;
                    Item : out Num ;
                    Last : out Positive ) ;

but it require an extra variable.

      String_Position : Positive ;
      ...
      Get ( Value,  Float_String, String_Position ) ;
      ...



In <newscache$sc454k$rp5$1@pleione.3soft.de>, "Alexander Camek" <Alexander.Camek@Elektrobit.com> writes:
>Hi List,
>
>is there another way to convert a given String to an Integer or Float type?
>
>I am currently using some code like this:
>
>begin
>Value :=Float'Value(Float_String);
>exception
>when Constraint_Error => Value := 0.0;
>end;
>
>For me this is very ugly and a big hack.
>Thanks for any idea.
>
>Greetings
>
>Alexander 
>
>




  reply	other threads:[~2008-07-17  8:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-17  7:49 Converting Integer / Float to String Alexander Camek
2008-07-17  8:05 ` anon [this message]
2008-07-17  8:15 ` Dmitry A. Kazakov
2008-07-17  8:32   ` Alexander Camek
2008-07-17  9:24     ` Dmitry A. Kazakov
2008-07-20  0:28 ` JPWoodruff
replies disabled

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