473,405 Members | 2,261 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Vb Equivalent of right shift operator ( >> )

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

Nov 21 '05 #1
3 4291
> 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

--
Pozdrav,
Josip Medved, MCSD
http://www.jmedved.com
Nov 21 '05 #2
Bob,

Some pages to help with language differences between C# and VBNet

Code C# and VB
http://www.harding.edu/USER/fmccown/...omparison.html

Language compare
http://msdn.microsoft.com/library/en...quivalents.asp
I hope this helps?

Cor
Nov 21 '05 #3
On Fri, 17 Sep 2004 17:59:56 -0700, Bob wrote:
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
--
Tom Shelton [MVP]
Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: David Briggs | last post by:
I am using MS VC++ 6.0 with MFC I have a simple class: #include <fstream.h> class Data { public: CString WriteStr(); Data();
3
by: Alex Vinokur | last post by:
Member operators operator>>() and operator<<() in a program below work fine, but look strange. Is it possible to define member operators operator>>() and operator<<() that work fine and look...
4
by: hall | last post by:
Hi all. I have run into a problem of overloading a templatized operator>> by a specialized version of it. In short (complete code below), I have written a stream class, STR, which defines a...
7
by: Susan Bricker | last post by:
I know that I saw some information concerning the <shift>+<enter> combination use to bypass launching an Access mdb application and enter the Access design workspace. Would someone please direct...
2
by: Bill | last post by:
I am trying to convert a Java APP to C# and it appears C# does not have a >>> operator. Does anyone the best way to conver this operator in to c#? Thanks. -- Bill
12
by: Mick_fae_Glesga | last post by:
OK, the solution to this is probably blindingly obvious to everyone, but... surely it can't be right. I am compiling with borland bcc32 free compiler this piece of code is designed to identify...
7
by: gokkog | last post by:
Hello, Recently I have the book Programming Pearls. Nice read! Perhaps it is weekend, I cannot understand the following codes well: #define BITSPERWORD 32 #define SHIFT 5 #define MASK 0x1F...
11
by: Noah Roberts | last post by:
template < typename T > std::istream & operator >(std::istream & in, std::pair<T,T& p) { in >p.first >p.second; return in; } .... std::istream_iterator< std::pair<size_type, size_type
6
by: puzzlecracker | last post by:
Say we have this structure: Struct Foo{ .... friend ostream& operator << (ostream& s, Foo & m); ..... }; friend ostream& operator << (ostream& s, Foo & m){
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.