Bitwise Encode '>|'
The Bitwise Encode operator encodes a 32-bit long value into the value (0 – 32) that represents the highest bit set, plus 1. Bitwise Encode can be used in variable and integer constant expressions, but not in floating-point constant expressions. Example:
PinNum := >|Pin
The above example sets PinNum equal to the number of the highest bit set in Pin, plus 1.
If Pin is %00000000 00000000 00000000 00000000, PinNum is set equal to 0; no bits are set.
If Pin is %00000000 00000000 00000000 10000000, PinNum is set equal to 8; bit 7 is set.
If Pin is %10000000 00000000 00000000 00000000, PinNum is set equal to 32; bit 31 is set.
If Pin is %00000000 00010011 00010010 00100000, PinNum is set equal to 21; bit 20 is the highest bit set.
Unless otherwise noted, content on this site is licensed under the
Creative Commons Attribution-ShareAlike 4.0 International License.