* float value without power
@ 2003-06-19 10:26 Etienne Baudin
2003-06-19 11:08 ` Dmitry A. Kazakov
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Etienne Baudin @ 2003-06-19 10:26 UTC (permalink / raw)
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 ?
Thanks
Etienne
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: float value without power
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
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Dmitry A. Kazakov @ 2003-06-19 11:08 UTC (permalink / raw)
Etienne Baudin wrote:
> 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 ?
1. If you want to use 'Image then you can convert the value to a fixed point
type and then use 'Image from that type.
2. You can use Put from Float_IO.
3. Alternatively http://www.dmitry-kazakov.de/ada/strings_edit.htm
--
Regards,
Dmitry A. Kazakov
www.dmitry-kazakov.de
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: float value without power
2003-06-19 10:26 float value without power Etienne Baudin
2003-06-19 11:08 ` Dmitry A. Kazakov
@ 2003-06-19 12:02 ` Martin Dowie
2003-06-19 13:47 ` Marqmc5
2003-06-20 2:48 ` Steve
3 siblings, 0 replies; 6+ messages in thread
From: Martin Dowie @ 2003-06-19 12:02 UTC (permalink / raw)
"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 ?
with Ada.Float_Text_IO; use Ada.Float_Text_IO;
with Ada.Text_IO; use Ada.Text_IO;
procedure Float_Output is
F : Float := 123.456;
begin
Put (F, Aft => 3, Exp => 0);
New_Line;
end Float_Output;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: float value without power
2003-06-19 10:26 float value without power Etienne Baudin
2003-06-19 11:08 ` Dmitry A. Kazakov
2003-06-19 12:02 ` Martin Dowie
@ 2003-06-19 13:47 ` Marqmc5
2003-06-20 2:48 ` Steve
3 siblings, 0 replies; 6+ messages in thread
From: Marqmc5 @ 2003-06-19 13:47 UTC (permalink / raw)
Try playing around with the 'fore', 'aft', and 'exp' parameters on the
put/put_line statements.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: float value without power
2003-06-19 10:26 float value without power Etienne Baudin
` (2 preceding siblings ...)
2003-06-19 13:47 ` Marqmc5
@ 2003-06-20 2:48 ` Steve
3 siblings, 0 replies; 6+ messages in thread
From: Steve @ 2003-06-20 2:48 UTC (permalink / raw)
"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
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2003-06-20 2:48 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox