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

Jacob Carlborg via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon May 1 12:06:36 PDT 2017


On 2017-05-01 17:45, 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?

Not sure if this is still the case. But this [1] suggests that D doesn't 
have an evaluation order defined but Java does.

[1] http://dsource.org/projects/dwt/wiki/Porting#Evaluationorder

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list