Recursion makes very little sense performance wise:Code:Function LShift(ByVal Num As Long, ByVal Bits As Byte) As Long If Bits < 32 Then For Bits = 1 To Bits: Num = (Num And &H3FFFFFFF) * 2 Or -((Num And &H40000000) > 0) * &H80000000: Next LShift = Num End If End Function Function RShift(ByVal Num As Long, ByVal Bits As Byte) As Long If Bits < 32 Then If Bits Then Num = (Num And &H7FFFFFFF) \ 2 Or -(Num < 0) * &H40000000 For Bits = 2 To Bits: Num = Num \ 2: Next RShift = Num End If End Function




Reply With Quote