views:

13

answers:

1

hi,

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

Please what am i doing wrong?

Thanks.

+1  A: 

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.

KennyTM
i have tried CUInt, CUShort and CULng but i get errors overflow errors
CharlesO