RemoveBitValue
See Also: Miscellaneous Functions, AddBitValue, IsFlagIn, IAND operator, IOR operator
Purpose
Zeros (clears) the bit pattern of one integer in another.
Return Type
Syntax
Use GlobalFunctionsProcedures.pkg
(RemoveBitValue({iBitValue}, {iSource}))
Parameters
- {iBitValue}: A single binary digit to clear in {iSource}.
- {iSource}: The integer value to clear binary digits in using {iBitValue}.
What It Does
RemoveBitValue compares the binary digits of two integers, {iBitValue} and {iSource}. An integer value is returned where, for the binary digit in {iBitValue} = 1, the corresponding digit in {iSource} is set to 0.
For example:
RemoveBitValue(16, 2704) = 2688
We can see this by inspecting the binary values of each integer:
2704: 1010 1001 0000
16: 0000 0001 0000
2688: 1010 1000 0000
If {iBitValue} has more than one binary digit = 1, then no operation is performed and the value returned is {iSource}. Thus, RemoveBitValue is only to be used for clearing a single binary digit in {iSource}.
For example:
RemoveBitValue(255, 2704) = 2704
Examples
Use GlobalFunctionsProcedures.pkg
Procedure Test
Integer iResult
Move (RemoveBitValue(16, 2704)) to iResult
Send Info_Box("Result = " + String(iResult)) "Test"
End_Procedure
Notes
RemoveBitValue is useful for binary encoding information into a single integer value.