comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <jrcarter@acm.org>
Subject: Re: Why raises this an error? :-(
Date: Sat, 16 Mar 2002 20:37:09 GMT
Date: 2002-03-16T20:37:09+00:00	[thread overview]
Message-ID: <3C93ACE5.36B3BCE2@acm.org> (raw)
In-Reply-To: 3C93A19C.67D6E442@t-online.de

Kai Gl�sner wrote:
> 
> 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!

Exponentiation has higher precedence than unary minus (ARM 4.5), so this
is equivalent to

Alt_D := -(2.0 ** 2.0);

ARM A.5.1 says that Argument_Error is raised "by the exponentiation
operator, when the value of the left operand is negative". This is the
case in your first example.

Since your exponent is an integer value, you can avoid this restriction
by using the predefined exponentiation operator for floating-point
types:

Alt_D := (-8.0 / 4.0) ** 2;

-- 
Jeff Carter
"Your mother was a hamster and your father smelt of elderberries."
Monty Python & the Holy Grail



  parent reply	other threads:[~2002-03-16 20:37 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
2002-03-17 16:31   ` Steve Doiel
2002-03-16 20:37 ` Jeffrey Carter [this message]
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