From: Damien Carbonne <damien.carbonne@free.fr>
Subject: Re: Why raises this an error? :-(
Date: Sat, 16 Mar 2002 21:32:04 +0100
Date: 2002-03-16T21:27:12+01:00 [thread overview]
Message-ID: <3C93ABC4.C27E9D5F@free.fr> (raw)
In-Reply-To: 3C93A19C.67D6E442@t-online.de
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
next prev parent reply other threads:[~2002-03-16 20:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-03-16 19:48 Why raises this an error? :-( Kai Gläsner
2002-03-16 20:32 ` Damien Carbonne [this message]
2002-03-17 16:31 ` Steve Doiel
2002-03-16 20:37 ` Jeffrey Carter
2002-03-16 22:01 ` Kai Gläsner
2002-03-17 5:39 ` Jeffrey Carter
2002-03-17 7:25 ` Hyman Rosen
2002-03-16 22:12 ` Kai Gläsner
2002-03-17 1:06 ` tmoran
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox