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