473,394 Members | 1,645 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,394 software developers and data experts.

circular left shift in VB

Hello Folks,

i hava a problem in coding of circular left shift of 25 bits in my
program...how do i perform it, and how do i use unsigned in VB.
My program (IDEA algorithm implementation in VB) requires unsigned
bits...so how do i go thro this ,since VB does not support unsigned
operations
Post your suggestions!!!

Many thanks,
Sandhya

Jul 11 '06 #1
4 4236
Could you give some more details, perhaps code snippets?

"sandhya" <sa******@gmail.comwrote in message
news:11*********************@75g2000cwc.googlegrou ps.com...
Hello Folks,

i hava a problem in coding of circular left shift of 25 bits in my
program...how do i perform it, and how do i use unsigned in VB.
My program (IDEA algorithm implementation in VB) requires unsigned
bits...so how do i go thro this ,since VB does not support unsigned
operations
Post your suggestions!!!

Many thanks,
Sandhya

Jul 11 '06 #2
sandhya wrote:
bits...so how do i go thro this ,since VB does not support unsigned
operations
If you have VB2005, it does support unsigned values using the UShort,
UInteger, ULong types.

But you can still use signed types as the bits will still be shifted.

Can you provide a little more detail on what you are attempting to do?

Jul 11 '06 #3

sandhya wrote:
i hava a problem in coding of circular left shift of 25 bits in my
program...how do i perform it, and how do i use unsigned in VB.
My program (IDEA algorithm implementation in VB) requires unsigned
bits...so how do i go thro this ,since VB does not support unsigned
operations
<snip>

You may try the following, although I must warn you that I didn't have
the time to stress test it:

Function LRoll25(ByVal Value As Integer, _
ByVal Count As Integer) As Integer
If Count >= 0 Then
Return ((Value << Count) And &H1FFFFFF) _
Or ((Value And &H1FFFFFF) >(25 - (Count Mod 26)))
Else
Return ((Value And &H1FFFFFF) >-Count) _
Or ((Value << (25 + (Count Mod 26)) And &H1FFFFFF))
End If
End Function

Count is the number of bits to roll left. Bits that fall beyond the
25th position (from right to left) will be rolled back into the value
from the right side. Negative values for Count will roll right
(yikes!).

Have fun, and best regards.

Branco.

Jul 11 '06 #4
i hava a problem in coding of circular left shift of 25 bits in my
program...how do i perform it, and how do i use unsigned in VB.
My program (IDEA algorithm implementation in VB) requires unsigned
bits...so how do i go thro this ,since VB does not support unsigned
operations
If you represent 25 bits as the low order 25 bits in a 32 bit integer, then
you can use the routine below. m is an integer whose low order 25 bits are
to be shifted. s is the number of bits to right shift, or if s is negative,
left shift.

Public Function ShiftRightCircular25(ByVal m As Integer, ByVal s As
Integer) As Integer
' Circular right shift the low order 25 bits of m by s bits.
' If s is negative, then circular left shift by -s bits.
' Return the shifted value with the high order 7 bits zeroed.
' The technique is to make two adjacent copies of m (50 bits total) in a
long,
' and then right shift an appropriate amount to handle a left or right
shift.
Const Mask As Long = &H1FFFFFF ' 25 low order 1 bits
Const Dup25 As Long = Mask + 2 ' a multiplier that duplicates 25 low
order bits
Dim x As Long = (m And Mask) * Dup25 ' two copies of m are now adjacent
in x
s = s Mod 25 ' a shift amount within the bounds -24 <= s <= +24
If s < 0 Then s += 25 ' convert a left shift to a right shift
x >>= s ' the low order 25 bits of x contain the output
Return CInt(x And Mask)
End Function

Jul 11 '06 #5

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

Similar topics

4
by: Kevin | last post by:
I was looking through some source code and noticed the used of the C# << operator. Why is this being used here and under what circumstances is an left-shift operator useful. internal enum...
56
by: Christian Christmann | last post by:
Hi, in the header of my class I've a constant static const int a = ( 1 << 32 ) - 1; When compiling the code, g++ issues the warning "warning: left shift count >= width of type" Why? And...
1
by: aliasger.jaffer | last post by:
Hi, I have an array A of type short, and I want to left shift the value in index 0 by four. I tried the following statement: A << = 4; Unfortunately, I get the following error when I try to...
4
by: ankitabhatia | last post by:
i ave a byte array..ave 2 left shift it by 25 bits.. to be able 2 reuse de elements of de array.. ave to do this for encryption algo.. ne help will b gr8..thnx a lot:):) btw i need it in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.