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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,79720e5f1992e61e X-Google-Attributes: gid103376,public From: "John G. Volan" Subject: Re: Math functions in Ada Date: 1997/05/17 Message-ID: <337E5534.4557@sprintmail.com>#1/1 X-Deja-AN: 242877139 References: <5ka4nc$man@news1.mnsinc.com> <5lhvrk$cqj@mtinsc05.worldnet.att.net> Organization: Sprint Internet Passport Reply-To: johnvolan@sprintmail.com Newsgroups: comp.lang.ada Date: 1997-05-17T00:00:00+00:00 List-Id: > wfrye@mnsinc.com (William Frye) wrote: > > >Is a there a source of freeware Ada routines for simple math functions? > >I am particularly interested in a routine to calculate x**y where x and y > >are floating point numbers. I am working with gnat on a Win95 platform. Of course there is such a source! In fact, you already have it! (See below...) Jacob S. Rosenberg. wrote: > > Hi William, > > First of all, x**y equals exp(y * log(x)). So, all you need are the > log (logarithm) and exp (exponential) functions. It should be failrly > easy to write such a function as log and exp are generally provided. > Indeed, the whole thing would be: > > return exp(y * log(x)); > > I strongly recommend that the input values and the functions used are > of type long_float and not float in order to provide greater range and > accuracy. The function itself could return a float. In that case, > you can do a conversion to float before the return statement. Why in heaven's name would you want to re-invent the wheel, when "**" is already provided in the standard library? See ARM A.5.1 Elementary Functions: generic type Float_Type is digits <>; package Ada.Numerics.Generic_Elementary_Functions is ... function "**" (Left, Right : Float_Type'Base) return Float_Type'Base; ... ------------------------------------------------------------------------ Internet.Usenet.Put_Signature (Name => "John G. Volan", Home_Email => "johnvolan@sprintmail.com", Slogan => "Ada95: The World's *FIRST* International-Standard OOPL", Disclaimer => "These opinions were never defined, so using them " & "would be erroneous...or is that just nondeterministic now? :-) "); ------------------------------------------------------------------------