comp.lang.ada
 help / color / mirror / Atom feed
From: nasser@apldbio.com (Nasser Abbasi)
To: alcilcius@thirdsigma.mv.com (Al Cilcius)
Subject: Re: how to convert float number into char string?
Date: 1996/06/15
Date: 1996-06-15T00:00:00+00:00	[thread overview]
Message-ID: <nhpw71qgkb.fsf@paralysys> (raw)
In-Reply-To: 31BDD755.53E4@thirdsigma.mv.com



Since this was shown in C and C++, we might as well show it in Ada 
for completion sake :)


--
-- move float number to string... Ada95 version ... Nasser Abbasi
--

with Ada.Text_Io; use Ada.Text_Io;
with Ada.Strings.Fixed; use Ada.Strings.fixed;

procedure My_Float is
  type Float_Type is digits 10;  --  lets have a 10 digits float number
  Fs: String(1..80);
  F: Float_Type;
begin

  F:=2.57876453;                                -- give it some value

  Put_Line("float is " & Float_Type'Image(F)); -- print it

  -- print how many digits our floating variable has
  Put_Line("f has this many digits=" & Integer'Image(Float_Type'Digits));

  Move(Float_Type'Image(F),Fs);             -- move the float to string

  Put_line(Fs);    -- and print the string to make sure it is there 
end My_Float;
-- 
Nasser Abbasi. C/C++/Ada Solaris. GeneAssist - A client/server 
application for Nucleic acid and protein sequence search and analysis.
PE-Applied BioSystem division. email:  nasser@apldbio.com   
MSEE, MSCS, MSCE, FM (and Karpov is my chess hero! ..).




           reply	other threads:[~1996-06-15  0:00 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <31BDD755.53E4@thirdsigma.mv.com>]
replies disabled

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