Vb Equivalent of right shift operator ( >> )

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

What is an equivalent of a Right Shift operator (>>) in
visual basic 6.0? I am trying to convert a C++ code into
visual basic that looks like the following:

While (m < n)
{
k = (m+n) >> 1
}

Thanks,
Bob
 
What is an equivalent of a Right Shift operator (>>) in
visual basic 6.0? I am trying to convert a C++ code into
visual basic that looks like the following:

I use this:

Dim lookupMask32Pwr() As Integer = {&H1, &H2, &H4, &H8, &H10, &H20, &H40,
&H80, &H100, &H200, &H400, &H800, &H1000, &H2000, &H4000, &H8000, &H10000,
&H20000, &H40000, &H80000, &H100000, &H200000, &H400000, &H800000,
&H1000000, &H2000000, &H4000000, &H8000000, &H10000000, &H20000000,
&H40000000, &H80000000}

Public Overloads Shared Function ShiftRight(ByVal data As Integer, ByVal
amount As Integer) As Integer
If (amount <= 0) Then
Return data
ElseIf (amount > 31) Then
Return 0
Else
If (data And lookupMask32Pwr(31)) = lookupMask32Pwr(31) Then
Return (data And &H7FFFFFFF) \ lookupMask32Pwr(amount) Or
lookupMask32Pwr(31 - amount)
Else
Return data \ lookupMask32Pwr(amount)
End If
End If
End Function
 
What is an equivalent of a Right Shift operator (>>) in
visual basic 6.0? I am trying to convert a C++ code into
visual basic that looks like the following:

While (m < n)
{
k = (m+n) >> 1
}

Thanks,
Bob

If your using 2003 or better - then, the answer would be >> :)

k = (m + n) >> 1

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top