(int << ulong) == int ?

Dmitry Olshansky dmitry.olsh at gmail.com
Sun Aug 7 13:33:31 PDT 2011


Just lost the best part of an hour figuring the cause of this small 
problem, consider:

void main()
{
         uint j = 42;
         ulong k = 1<<cast(ulong)j;
         ulong m = 1UL<<j;
         assert(k == 1024);//both asserts do pass
         assert(m == (1UL<<42));
}

I though left operand should be promoted to the largest integer in shift 
expression, isn't it?

-- 
Dmitry Olshansky



More information about the Digitalmars-d-learn mailing list