typing base ^^ exp

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Feb 14 12:56:04 PST 2010


I've tested the typing rules for ^^ and they seem wanting. One painful 
example:

     int a2 = 3, b2 = -2;
     writeln(typeof(a2 ^^ b2).stringof);
     writeln(a2 ^^ b2);

The program writes:

int
zsh: floating point exception  ./test.d

Ouch. Here's what I suggest:

====
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 @exp at . If at least one of the operands has a floating point
type,  the result  type is  the largest  participating  floating point
type.
====

Makes sense?


Andrei



More information about the Digitalmars-d mailing list