June 26, 1999

BitSet – Set a bit in a number

‘ Set a bit in a value” NOTE: requires Power2()Function BitSet(ByVal value As Long, ByVal bit As Long) As Long ‘ simply OR with the bit mask ‘ Range checking

Power2 – A power of 2

‘ Raise 2 to a power’ the exponent must be in the range [0,31]Function Power2(ByVal exponent As Long) As Long Static res(0 To 31) As Long Dim i As Long

ShiftRight – Shift a Long to the right

‘ Shift to the right of the specified number of times” NOTE: requires Power2()Function ShiftRight(ByVal value As Long, ByVal times As Long) As Long ‘ we need to create a

RotateRight – Rotate a Long to the right

‘ Rotate a Long to the right the specified number of times” NOTE: requires Power2()Function RotateRight(ByVal value As Long, ByVal times As Long) As Long Dim i As Long, signBits

RotateLeft – Rotate a Long to the left

‘ Rotate a Long to the left the specified number of times” NOTE: requires Power2()Function RotateLeft(ByVal value As Long, ByVal times As Long) As Long Dim i As Long, signBits

BitToggle – Invert a bit in a value

‘ Toggle a bit in a value” NOTE: requires Power2()Function BitToggle(ByVal value As Long, ByVal bit As Long) As Long ‘ simply XOR with the negation of the bit mask

RotateRightI – Rotate an Integer to the right

‘ Rotate an Integer to the right the specified number of times” NOTE: requires Power2()Function RotateRightI(ByVal value As Integer, ByVal times As Long) As Integer Dim i As Long, signBits

RotateLeftI – Rotate an Integer to the left

‘ Rotate an Integer to the left the specified number of times” NOTE: requires Power2()Function RotateLeftI(ByVal value As Integer, ByVal times As Long) As Integer Dim i As Long, signBits