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 <<开发者_如何学Go; b) Or (CUShort(a) >> (32 - b)))
End Function
What am I doing wrong?
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.
精彩评论