Porting Java code to D that uses << and >>> operators

Basile B. via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon May 1 08:53:41 PDT 2017


On Monday, 1 May 2017 at 15:45:00 UTC, bachmeier wrote:
> I'm porting a small piece of Java code into D, but I've run 
> into this:
>
> int y1 = ((x12 & MASK12) << 22) + (x12 >>> 9) + ((x13 & MASK13) 
> << 7) + (x13 >>> 24);
>
> I have a basic understanding of those operators in both 
> languages, but I can't find a sufficiently detailed explanation 
> to tell me how to translate the Java into D and know that it's 
> guaranteed to give the same result. Can someone tell me the 
> correct D code to use?

It's the same code in D. It extracts consecutive bits in x12 and 
x13 (and maskxx), put them at the beginning (right shift) and add 
them.


More information about the Digitalmars-d-learn mailing list