Problems with shift left operator (dmd 0.169)

KlausO oberhofer at users.sf.net
Wed Oct 11 07:00:03 PDT 2006


Lionello Lunesu wrote:
> 
> I think 32 should be illegal also. It would append 32 0-bits, which 
> means the result (uint) will always be 0.
> 

Are there practical uses for shifting more than 32 bits ?

Example: Calculating a mask
   uint mask = (1 << nbits) - 1;

Of course, you could express this also as
   uint mask = (0xffffffff >> (32 - nbits));



More information about the Digitalmars-d-learn mailing list