comp.lang.ada
 help / color / mirror / Atom feed
From: "Bob Fletcher" <bob@radge.globalnet.co.uk>
Subject: Re: strings to floats/integers
Date: 1998/09/03
Date: 1998-09-03T00:00:00+00:00	[thread overview]
Message-ID: <01bdd730$3130dd90$f330ea9e@ukp03332> (raw)
In-Reply-To: 35e41033.9324314@200.223.0.87

You can use two things called 'image and 'value.

The first converts to a string from another type (e.g.
Put(integer'image(2));)

The second goes the other way (e.g. x := 1 + integer'value("2");)

For your example use myfloat := float'value(mystring);

The only word of warning I would give is that you should be careful that
whatever is in the string can logically represent the type being converted
to. Maybe someone else can enlighten us on what happens if this is not the
case, I can't remember.

Hope this helps,
Bob Fletcher
bob@radge.globalnet.co.uk
http://www.users.globalnet.co.uk/~radge/

Mr Pinga <joke@haha.com> wrote in article
<35e41033.9324314@200.223.0.87>...
> 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
> 
> any info greatly appreciated
> 
> Jared
> 
> ps. Please email me if possible because i dont have a proper usenet
> connection
> 
> 




      parent reply	other threads:[~1998-09-03  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-08-26  0:00 strings to floats/integers Mr Pinga
1998-08-26  0:00 ` Richard D Riehle
1998-08-26  0:00   ` David C. Hoos, Sr.
1998-08-26  0:00     ` Richard D Riehle
1998-08-29  0:00   ` Matthew Heaney
1998-09-03  0:00 ` Bob Fletcher [this message]
replies disabled

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