Charles Okwuagwu
Charles Okwuagwu

Reputation: 10876

How do I translate the >>> operator in JavaScript to VB.NET?

I am doing code conversion from JavaScript to VB.NET. I am stuck with the >>> operation.

See the sample code and my attempt below:

JavaScript:

function test(a, b) {
    return (a << b) | (a >>> (32 - b))
}

My attempt in VB.NET:

Private Function test(ByVal a As Integer, ByVal b As Integer) As Integer
    Return ((a << b) Or (CUShort(a) >> (32 - b)))
End Function

What am I doing wrong?

Upvotes: 0

Views: 127

Answers (1)

kennytm
kennytm

Reputation: 523544

You should use CUInt instead of CUShort.

CUShort gives an UShort which is only 16-bit in size. In JavaScript all bit operations are done in 32-bit, so a should be converted to a 32-bit unsigned type as well — which is UInteger.

Upvotes: 1

Related Questions