comp.lang.ada
 help / color / mirror / Atom feed
From: mheaney@ni.net (Matthew Heaney)
Subject: Re: Ada function sqrt(x)
Date: 1996/09/22
Date: 1996-09-22T00:00:00+00:00	[thread overview]
Message-ID: <mheaney-ya023080002209961741020001@news.ni.net> (raw)
In-Reply-To: mheaney-ya023080002209961735440001@news.ni.net



Oops!  Of course I meant:


   generic
      type T is range <>;
   function Generic_Square_Root (N : T) return T'Base;

   function Generic_Square_Root (N: T) return T'Base is
      The_Square_Root : T'Base := N/2;
   begin
      loop
         declare
            The_New_Value : constant T'Base := 
               (The_Square_Root + N / The_Square_Root) / 2;
         begin
            exit when The_New_Value = The_Square_Root;
            The_Square_Root := The_New_Value;                  -- This
statement is important!
         end;
      end loop;

      return The_Square_Root;
   end Generic_Square_Root; 

matt

--------------------------------------------------------------------
Matthew Heaney
Software Development Consultant
mheaney@ni.net
(818) 985-1271




  reply	other threads:[~1996-09-22  0:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <01bba50c$7c1a2760$dc014dc6@MountainNet>
1996-09-18  0:00 ` Ada function sqrt(x) Pascal Obry
1996-09-20  0:00   ` Keith Thompson
1996-09-20  0:00     ` Roderick Chapman
1996-09-21  0:00     ` Robert Dewar
1996-09-21  0:00     ` Robert Dewar
1996-09-26  0:00       ` Keith Thompson
1996-09-22  0:00     ` Matthew Heaney
1996-09-22  0:00       ` Matthew Heaney [this message]
1996-09-24  0:00 W. Wesley Groleau (Wes)
replies disabled

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