Routines for bitwise and unsigned data manipulation.
Visual Basic does not provide any native methods for performing bitwise manipulation, nor does it provide unsigned data types. This module remedies those limitations with routines for bit shifting, setting and clearing bits, unsigned assignment operations, and extracting components of variables.
|
Procedure Name
|
Type
|
Description
|
|
(Declarations)
|
Declarations
|
Declarations and private variables for the modBitOps module
|
|
BitClearByte
|
Procedure
|
Clear a bit in a byte variable
|
|
BitClearInteger
|
Procedure
|
Clear a bit in a long variable
|
|
BitClearLong
|
Procedure
|
Clear a bit in a long variable
|
|
BitSetByte
|
Procedure
|
Set a bit in a byte variable
|
|
BitSetInteger
|
Procedure
|
Set a bit in an integer variable
|
|
BitSetLong
|
Procedure
|
Set a bit in a long variable
|
|
BitTestByte
|
Procedure
|
Test a bit to see if it is turned on
|
|
BitTestInteger
|
Procedure
|
Test a bit to see if it is turned on
|
|
BitTestLong
|
Procedure
|
Test a bit to see if it is turned on
|
|
dblToLong
|
Procedure
|
This routine does an unsigned conversion from a double value to a Long value.
This function correctly handles doubles greater than 2,147,483,647 and less than or equal to 4,294,967,295.
|
|
HiByte
|
Procedure
|
Returns the high byte of the passed integer
|
|
HiLong
|
Procedure
|
Returns the high long of the passed double
|
|
HiWord
|
Procedure
|
Returns the high integer of the passed long
|
|
IntToByte
|
Procedure
|
This routine does an unsigned conversion from an integer value to a byte value. It correctly handles any integer value.
|
|
IntToLong
|
Procedure
|
Convert an Integer value to a Long value, treating the integer as unsigned.
For example, performing the following assignment
lngNumber = -1
assigns -1 to the variable lngNumber. However, This assignment
lngNumber = IntToLong(-1)
assigns 65,535 to lngNumber.
|
|
LoByte
|
Procedure
|
Returns the low byte of the passed integer
|
|
LoLong
|
Procedure
|
Returns the low long of the passed double
|
|
LongToDbl
|
Procedure
|
This routine converts a Long value to a Double value, treating the long as unsigned.
For example, performing the following assignment
dblNumber = -1
assigns -1 to the variable dblNumber. However, This assignment
dblNumber = LongToDbl(-1)
assigns 4,294,967,295 to dblNumber.
|
|
LongToInt
|
Procedure
|
Perform an unsigned conversion from a Long value to an integer value
|
|
LoWord
|
Procedure
|
Returns the low integer of the passed long
|
|
MakeDbl
|
Procedure
|
Combines two longs into a double. This routine correctly handles negative input Values
|
|
MakeInt
|
Procedure
|
Combines two bytes into an integer.
|
|
MakeLong
|
Procedure
|
Combines two words (integers) into a long. This routine correctly handles negative input Values
|
|
Shlb
|
Procedure
|
Shifts a numeric value left the specified number of bits.
Left shifting can be defined as a multiplication operation. For the number of bits we want to shift a value to the left, we need to raise two to that power, then multiply the result by our original value.
|
|
Shli
|
Procedure
|
Shifts a numeric value left the specified number of bits.
Left shifting can be defined as a multiplication operation. For the number of bits we want to shift a value to the left, we need to raise two to that power, then multiply the result by our original value.
|
|
Shll
|
Procedure
|
Shifts a numeric Value left the specified number of bits.
Left shifting can be defined as a multiplication operation. For the number of bits we want to shift a value to the left, we need to raise two to that power, then multiply the result by our original value.
|
|
Shrb
|
Procedure
|
Shifts a byte value right the selected number of places.
Right shifting can be defined as a division operation. For the number of bits we want to shift a value to the right, we need to raise two to that power, then our original value by the result.
|
|
Shri
|
Procedure
|
Shifts a Long value right the selected number of places.
Right shifting can be defined as a division operation. For the number of bits we want to shift a value to the right, we need to raise two to that power, then our original value by the result.
|
|
Shrl
|
Procedure
|
Shifts a Long value right the selected number of places.
Right shifting can be defined as a division operation. For the number of bits we want to shift a value to the right, we need to raise two to that power, then our original value by the result.
|