Show TOC

Comparisons Between Bit SamplesLocate this document in the navigation structure

Using the operators O, Z, and M (see keyword documentation), you can compare the bit sequence of the first operand with that of the second: 

Tip

Important: 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 list output is as follows:

00          001          102          203          340         6441         6542         6643         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 Sequence

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.