Entering content frameComparing Bit Sequences Locate the document in its SAP Library structure

Use the following three operators to compare the bit sequence of the first operand with that of the second:

<operator>

Meaning

O

bits are one

Z

bits are zero

M

bits are mixed

The second operand must have type X. The comparison takes place over the length of the second operand. The first operand is not converted to type X.

The function of the operators is as follows:

O (bits are one)

The logical expression

<f> O <hex>

is true if the bit positions that are 1 in <hex>, are also 1 in <f>. In terms of set operations with bit sequences, this comparison is the same as finding out whether the set represented by <hex> is a subset of that represented by <f>.

Z (bits are zero)

The logical expression

<f> Z <hex>

is true if the bit positions that are 1 in <hex>, are 0 in <f>.

M (bits are mixed)

The logical expression

<f> M <hex>

is true if from the bit positions that are 1 in <hex>, at least one is 1 and one is 0 in <f>.

Example

Caution: The following programs are no longer supported in Unicode systems:

REPORT demo_log_expr_bits .

DATA: text(1) TYPE c VALUE 'C',
      hex(1) TYPE x,
      i TYPE i.

hex = 0.

DO 256 TIMES.

  i = hex.

  IF text O hex.
    WRITE: / hex, i.
  ENDIF.

  hex = hex + 1.

ENDDO.

The output is as follows:

00          0
01          1
02          2
03          3
40         64
41         65
42         66
43         67

Here, the bit structure of the character 'C' is compared to all hexadecimal numbers HEX between '00' and 'FF' (255 in the decimal system), using the operator O. The decimal value of HEX is determined by using the automatic type conversion during the assignment of HEX to I. If the comparison is true, the hexadecimal number and its decimal value are displayed on the screen. The following table shows the bit sequences of the numbers:

hexadecimal

decimal

Bit sequences

00

0

00000000

01

1

00000001

02

2

00000010

03

3

00000011

40

64

01000000

41

65

01000001

42

66

01000010

43

67

01000011

The bit sequence of the character 'C' is defined for the current hardware platform by its ASCII code number 67. The numbers that occur in the list display are those in which the same bit position is filled with 1 as in the bit sequence of ‘C’. The sequence 01000011 is the universal set of the bit sequences.

 

 

Leaving content frame