# TESTB (Test Bit)

Code |
Factor 1 |
Factor 2 |
Result Field |
Indicators |
||
---|---|---|---|---|---|---|

TESTB |
Bit numbers |
Character
field |
OF | ON | EQ |

The TESTB operation compares the bits identified in factor 2 with the corresponding bits in the field named as the result field. The result field must be a one-position character field. Resulting indicators in positions 71 through 76 reflect the status of the result field bits. Factor 2 is always a source of bits for the result field.

Factor 2 can contain:

*Bit numbers 0-7:*From 1 to 8 bits can be tested per operation. The bits to be tested are identified by the numbers 0 through 7. (0 is the leftmost bit.) The bit numbers must be enclosed in apostrophes. For example, to test bits 0, 2, and 5, enter ‘025’ in factor 2.*Field name:*You can specify the name of a one-position character field, table name, or array element in factor 2. The bits that are on in the field, table name, or array element are compared with the corresponding bits in the result field; bits that are off are not considered. The field specified in the result field can be an array element if each element of the array is a one-position character field.*Hexadecimal literal or named constant:*You can specify a 1-byte hexadecimal literal or hexadecimal named constant. Bits that are on in factor 2 are compared with the corresponding bits in the result field; bits that are off are not considered.

Figure 1 illustrates uses of the TESTB operation.

Indicators assigned in positions 71 through 76 reflect the status
of the result field bits. At least one indicator must be assigned,
and as many as three can be assigned for one operation. For TESTB
operations, the resulting indicators are set on as follows:

*Positions 71 and 72:*An indicator in these positions is set on if the bit numbers specified in factor 2 or each bit that is on in the factor 2 field is off in the result field. That is, all of the specified bits are equal to off.*Positions 73 and 74:*An indicator in these positions is set on if the bit numbers specified in factor 2 or the bits that are on in the factor 2 field are of mixed status (some on, some off) in the result field. That is, at least one the specified bits is on.Note: If only one bit is to be tested, these positions must be blank. If a field name is specified in factor 2 and it has only one bit on, an indicator in positions 73 and 74 is not set on.*Positions 75 and 76:*An indicator in these positions is set on if the bit numbers specified in the factor 2 or each bit that is on in factor 2 field is on in the result field. That is, all of the specified bits are equal to on.Note: If the field in factor 2 has no bits on, then no indicators are set on.

For more information, see Bit Operations or Test Operations.