From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,622fd11f5eb54423,start X-Google-Attributes: gid103376,public From: mhall59@us.net (Michael W. Hall) Subject: how to make a package???? Date: 1996/08/15 Message-ID: <4uu2kp$32u@news.us.net>#1/1 X-Deja-AN: 174269960 organization: US Net, Incorporated content-type: Text/Plain; charset=US-ASCII mime-version: 1.0 newsgroups: comp.lang.ada Date: 1996-08-15T00:00:00+00:00 List-Id: 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;