Andrei Alexandrescu <[email protected]> wrote:

====
The type of  the power expression is: @uint@ if  both @base@ and @exp@
have unsigned  types less  than @ulong@; @int@  if @base@ is  a signed
integer  less than  @long@ and  @exp@ is  an unsigned  type  less than
@ulong@; @ulong@ if  both @base@ and @exp@ have  unsigned types and at
least  one is  @ulong@; @long@  if @base@  is @long@  and @exp@  is an
unsigned  type; and @double@  for all  other combinations  of integral
@base@ and @e...@. If at least one of the operands has a floating point
type,  the result  type is  the largest  participating  floating point
type.
====

Makes sense?

I believe any and all powExps with integral base and exp should yield an
integral result. If you want a double, you ask for it with a cast.

Especially, as Don pointed out, when positive integral literals in D are
typed as int. "WTF? foo( 2^^2 ) complains about doubles? It don't do
that when I do uint x = 2; foo( 2^^x )!"

--
Simen

Reply via email to