From: Kurt Baty (kurt@wsfdb.wsfdb.com)
Date: Fri Mar 01 2002 - 08:53:47 PST
Precedence: bulk
> Paul Graham wrote:
> >
> > I think that the rule about exponentiation was intended to cover the case of
> > a negative exponent. So:
> >
> > x ** -1
> >
> > will generally be a real number. The text:
> >
> > The result of the power operator shall be real if either operand is a
> > real,integer,or signed.
> >
> > should be changed to read:
> >
> > The result of the power operator shall be real if either operand is
> > real, or if the second operand is negative.
Dennis Marsa wrote:
>
> I like first part (result is real if either operand is real),
> but not the second. The second operand could be a variable,
> and at compilation time we would not necessarily know if it
> is negative or not.
>
> integer x, y;
>
> x ** y; // real or integer?
>
> Shouldn't the result type be determinable statically?
>
if integer y can be negative, which it can, then the result
z = x ** y; // must be real!
Shalom Bresticker wrote:
> I remember looking at this some time ago.
>
> I thought I sent an email about it, but I can not find it, so maybe I did not.
>
> Anyway, my conclusion was that the paragraph is badly worded, and where it says
> "integer", it means a variable of type "integer".
> Where it says "signed", it means a signed reg or a signed constant.
> "Unsigned" means an unsigned reg or an unsigned constant.
>
> Then in your case, 2**5, both operands are unsigned constants, so the result is
> of type integer.
>
> The text of the standard should be fixed.
I wrote this "badly worded" text of the standard, and
I would be the first to admit I am no writer!
but my intent was as Shalom says "integer", it means a variable of type "integer".
Where it says "signed", it means a signed reg or a signed constant.
"Unsigned" means an unsigned reg or an unsigned constant.
Dennis Marsa wrote:
> But, unsized (with no base specifier) integer constants are signed,
> aren't they? I believe that is what section 2.5.1 on Integer Constants
> says.
>
> So, even with your modified wording, 2**5 would still be real.
>
> One would have to do something like 'd2**'d5 to get an integer
> result.
>
> That still seems really awkward.
I am not sure that this is the case.
2**5
should be the
(unsigned constant 2) ** (unsigned constant 5)
and thus unsigned constant 32
Kurt Baty
This archive was generated by hypermail 2.1.4
: Mon Jul 08 2002 - 12:55:35 PDT
and
sponsored by Boyd Technology, Inc.