Truth Set Test

From the characters in a TRUTHSET declaration, the compiler builds a truth set table, which is used in a truth set test to determine whether a given character is a member of that group of characters.

All truth sets declared by a single TRUTHSET declaration are stored in a single read-only array. Separate TRUTHSET declarations produce separate read-only arrays.

A truth set test references a bit in the read-only array containing the truth set by dividing the binary representation of the character being tested into two parts: the low-order five bits are used as a bit index, and the three high-order bits are used as a word index. If the size of the source character is smaller than eight bits, high-order zero bits are inserted to make an 8-bit character before the indexing algorithm is used.

The word index selects a particular word in the truth set table. The bit index is then subtracted from 31, and the result is used to reference one of the low-order 32 bits in the selected word. If the bit selected by the following expression is equal to 1, the character is a member of the truth set:

TABLE[CHAR.[7:3]].[(31-CHAR.[4:5]):1]

Truth Set Test shows an example of a truth set test. In this example, the referenced bit (13) is equal to 1; therefore, the test character is a member of the truth set.

Figure 2. Truth Set Test

Truth Set Test