Does D have too many features?

jerro a at a.com
Sun Apr 29 23:37:09 PDT 2012


> Sorry, I managed to get myself confused here. What I meant to 
> say was that I think >> should do an arithmetic shift if the 
> operands are signed; unsigned shift otherwise.

It does arithmetic shift if the left operand is signed,
unsigned shift otherwise. This code:

void main()
{
     int a = 0xffffffff;
     uint b = a;
     writefln("%x", a >> 1);
     writefln("%x", b >> 1);
}

prints

ffffffff
7fffffff



More information about the Digitalmars-d mailing list