comp.lang.ada
 help / color / mirror / Atom feed
* Float to string conversion
@ 1999-03-18  0:00 dd5372
  1999-03-18  0:00 ` Marin David Condic
  1999-03-18  0:00 ` John Herro
  0 siblings, 2 replies; 3+ messages in thread
From: dd5372 @ 1999-03-18  0:00 UTC (permalink / raw)


I'm using Rapid to build a GUI interface for a simple demo program and need to
be able to convert float values to strings.  Using the 'image property is okay
for integers, but using it on floats gives me the default Ada scientific
notation for floats.  Any suggestions?

Thanks - Dave

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Float to string conversion
  1999-03-18  0:00 Float to string conversion dd5372
@ 1999-03-18  0:00 ` Marin David Condic
  1999-03-18  0:00 ` John Herro
  1 sibling, 0 replies; 3+ messages in thread
From: Marin David Condic @ 1999-03-18  0:00 UTC (permalink / raw)


dd5372@my-dejanews.com wrote:
> 
> I'm using Rapid to build a GUI interface for a simple demo program and need to
> be able to convert float values to strings.  Using the 'image property is okay
> for integers, but using it on floats gives me the default Ada scientific
> notation for floats.  Any suggestions?
> 
You'll want to investigate Ada.Text_IO.Float_IO and look at the "Put"
procedures. One of them looks kind of like this:

procedure Put (
    To   : out String ;
    Item : in Num ;
    Aft  : in Field := Default_Aft ;
    Exp  : in Field := Default_Exp) ;

See also ARM A.10.9 for more details

Note that you get a pre-instantiated version of this package called
Ada.Float_Text_IO (ARM A.10.9{32..34}) for the standard type Float. That
makes the job just a little easier.

MDC

-- 
Marin David Condic
Real Time & Embedded Systems, Propulsion Systems Analysis
United Technologies, Pratt & Whitney, Large Military Engines
M/S 731-95, P.O.B. 109600, West Palm Beach, FL, 33410-9600
***To reply, remove "bogon" from the domain name.***




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Float to string conversion
  1999-03-18  0:00 Float to string conversion dd5372
  1999-03-18  0:00 ` Marin David Condic
@ 1999-03-18  0:00 ` John Herro
  1 sibling, 0 replies; 3+ messages in thread
From: John Herro @ 1999-03-18  0:00 UTC (permalink / raw)


dd5372@my-dejanews.com wrote:
> I ... need to ... convert float values to strings.
> Using the 'image property ... on floats gives
> me the default Ada scientific notation for floats.

In the package Ada.Float_Text_IO is

procedure Put(To : out String;
     Item : in Float;
     Aft : in Field := ...;
     Exp : in Field := ...);

where Field is a subtype of Integer.  This writes to a String, letting you
specify the number of places after the decimal point and the size of the
exponent field, which can be zero.  That should do it for you.
- John Herro
You can download a shareware AdaTutor program at
http://members.aol.com/AdaTutor




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-03-18  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-03-18  0:00 Float to string conversion dd5372
1999-03-18  0:00 ` Marin David Condic
1999-03-18  0:00 ` John Herro

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