This function provides an easy way to pick a certain bit from a value. It does not access any I/O, but rather provides a much easier way to pick a bit than standard REXX functions do. The format of the function is:
return_bit_value = RTBitPick( value, bit_position )
The value is in decimal with a range of 0 to 65535.
bit_position is the position of the bit which value is to be extracted. The right-most position (and therefore the least significant bit) is 0, the left-most (or most significant bit) position is 15.
return_bit_value is the value returned and can only be 0 or 1.
There is no variable range checking, so you must insure that the right values are passed along in the function.
Example:
The code below illustrates the RTBitPick function.
SAY 'The bit position 0 of the value 254 is ' || RTBitPick( '254', '0' )
SAY 'The bit position 1 of the value 254 is ' || RTBitPick( '254', '1' )
Output:
The bit position 0 of the value 254 is 0
The bit position 1 of the value 254 is 1