comp.lang.ada
 help / color / mirror / Atom feed
From: "Steve" <nospam_steved94@attbi.com>
Subject: Re: float value without power
Date: Fri, 20 Jun 2003 02:48:47 GMT
Date: 2003-06-20T02:48:47+00:00	[thread overview]
Message-ID: <jCuIa.37517$vq.7762@sccrnsc04> (raw)
In-Reply-To: bcs323$925$1@news-reader13.wanadoo.fr

"Etienne Baudin" <pfox@pas.de.spam.free.fr> wrote in message
news:bcs323$925$1@news-reader13.wanadoo.fr...
> If F is 123.456
> float'image(F) will be 1.2346e2. I Would like to get 123.465 in the
string,
> is it possible ?

Here's how I do it:

with Ada.Float_Text_Io;
with Ada.Strings;
with Ada.Strings.Fixed;
with Ada.Text_Io;
procedure DemoFormat is

  function Float_To_String( f : Float; aft : Natural ) return String is
    result : String( 1 .. 64 );
  begin
    Ada.Float_Text_Io.Put( result, f, aft, 0 );
    return Ada.Strings.Fixed.Trim( result, Ada.Strings.Both );
  end Float_To_String;

begin
  Ada.Text_IO.Put_Line( Float_To_String( 123.456, 3 ) );
end DemoFormat;

Steve
(The Duck)

>
> Thanks
> Etienne
>
>





      parent reply	other threads:[~2003-06-20  2:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-19 10:26 float value without power Etienne Baudin
2003-06-19 11:08 ` Dmitry A. Kazakov
2003-06-19 11:37   ` Etienne Baudin
2003-06-19 12:02 ` Martin Dowie
2003-06-19 13:47 ` Marqmc5
2003-06-20  2:48 ` Steve [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