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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ac6f692d19115ce0 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Exponent floats? Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: Date: Mon, 28 Mar 2005 08:49:28 +0200 Message-ID: <18pr9vfqxcnbs.3a905du0c170.dlg@40tude.net> NNTP-Posting-Date: 28 Mar 2005 08:49:18 MEST NNTP-Posting-Host: fec19f94.newsread4.arcor-online.net X-Trace: DXC=od\VAWLQ[EW8f4>W>BJ_OP:ejgIfPPldTjW\KbG]kaMXFYk:AnJB[C]a88JDYEXBLP[6LHn;2LCV^COgUkn_?_Y_LUEPKAmD8U\ X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:10058 Date: 2005-03-28T08:49:18+02:00 List-Id: On Mon, 28 Mar 2005 04:49:40 GMT, Puckdropper wrote: > I have an algorithm that requires a floating point exponent. How can I > use such a thing? I tried using **, but it gives me 3 errors: > > test.adb:12:24: invalid operand types for operator "**" > test.adb:12:24: left operand has type "Standard.float" > test.adb:12:24: right operand has type "Standard.float" > > To demonstrate my problem, I wrote a short program: > > ----------------------------- > > with Ada.Text_IO, Ada.Float_Text_IO; with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions; > procedure test is > > expon: float; > Answer: float; > Base: float; > > begin -- Main Program > expon := 2.0; > Base := 2.0; > Answer := base ** expon; Answer := exp (log (base) * expon); > Ada.Float_Text_IO.put(Answer); > Ada.Text_IO.new_line; > end test; ("**" is predefined for only integer powers, see ARM 4.5.6) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de