From: mhall59@us.net (Michael W. Hall)
Subject: how to make a package????
Date: 1996/08/15
Date: 1996-08-15T00:00:00+00:00 [thread overview]
Message-ID: <4uu2kp$32u@news.us.net> (raw)
I took a beginners course on ADA and now I am trying to learn some on my
own with book I bought, but there seems to be a big gap in the info
between the 2. I need to know how to make a package. I guess that will
allow me to put it somewhere without having to repeat code or whatever.
But at any rate I dont understand at all what Im doing. I have taken
this little square root procedure and was wondering if someone can tell
me what changes need to be made. The only thing I need to limit is
negative numbers. And I guess somehow I need to pass this tolerance to
the package so it can be variable. At any rate if anyone here knows what
Im talking about, can you take a look at it. There must be some simple
way to change a procedure to a package. Thanks. mhall59@us.net
---------------------------
with Text_IO;
procedure Square_Root is
package Float_IO is new Text_IO.Float_IO (Num => Float);
function Sqrt (Value : in Float) return Float is
Tolerance : constant := 0.000001;
Approx : Float;
begin
Approx := Value / 2.0;
Calculate_Square_Root:
loop
exit Calculate_Square_Root when abs(Approx ** 2 - Value) <
Tolerance;
Approx := 0.5 * (Approx + Value / Approx);
end loop Calculate_Square_Root;
return Approx;
end Sqrt;
begin
Float_IO.Put (Sqrt (16.0));
Text_IO.New_Line;
Float_IO.Put (Sqrt (15.0));
Text_IO.New_Line;
end Square_Root;
next reply other threads:[~1996-08-15 0:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-08-15 0:00 Michael W. Hall [this message]
1996-08-15 0:00 ` how to make a package???? John Herro
1996-08-15 0:00 ` Kevin J. Weise
1996-08-15 0:00 ` Michael W. Hall
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox