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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,587583eece659d7a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-03-16 12:27:14 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeed.berkeley.edu!ucberkeley!freenix!proxad.net!feeder2-1.proxad.net!news2-2.free.fr!not-for-mail Message-ID: <3C93ABC4.C27E9D5F@free.fr> Date: Sat, 16 Mar 2002 21:32:04 +0100 From: Damien Carbonne X-Mailer: Mozilla 4.78 [fr] (X11; U; Linux 2.4.8-26mdk i686) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Why raises this an error? :-( References: <3C93A19C.67D6E442@t-online.de> Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Organization: Guest of ProXad - France NNTP-Posting-Date: 16 Mar 2002 21:27:12 MET NNTP-Posting-Host: 62.147.144.8 X-Trace: 1016310432 news2-2.free.fr 23216 62.147.144.8 X-Complaints-To: abuse@proxad.net Xref: archiver1.google.com comp.lang.ada:21343 Date: 2002-03-16T21:27:12+01:00 List-Id: Kai Gl�sner a �crit : > Hello community, > > while porting an c++ math-library to Ada95 (Gnat 3.12p under Linux) I > experienced: > > This: > > Alt_D := (-8.0/4.0) ** 2.0; > > raises this: > > raised ADA.NUMERICS.ARGUMENT_ERROR : a-ngelfu.adb:111 instantiated > at a-nuelfu.ads:20 > > This: > > Alt_D := -2.0 ** 2.0; > > works fine! > > Why? What have I overlooked here... :-/ > > Thanks in advance for an answer... > > Kai Glaesner I am not completely sure, but there may be a precedence issue here. I think -2.0**2.0 is equivalent to -(2.0**2.0) whilst (-8.0/4.0)**2.0 is equivalent to (-2.0)**2.0. There is no general interpretation to the power of a negative number (except when the power is an integer value) Anyway, if what you need is the squarre value of a number, I think a simple multiplication is much faster than a general exponentiation algorithm. Regards Damien carbonne