Previous Topic: REXX Language in CA-GSSNext Topic: Convert Back to Binary Values


Binary Conversion in REXX

REXX deals only with character strings and not with the binary values used by IBM computers. So binary data must be converted to a character string. The following statement converts a binary value i to a character string:

i = C2D(i).

Before storing numeric values in memory, you can reconvert them back to binary values. The following statement converts a character string i to a 4- byte binary value:

i = D2C(i,4).

Example: Binary to Character Conversion

REXX treats the full word X'00000024' as a character string of length 4. If you try to print it, you get a 4‑byte unprintable string. If you try to use it numerically, you get a data conversion error. However, where i = X'00000024', coding i = C2D(i) converts i to its decimal equivalent of 36. REXX can perform arithmetic functions on this value.

Converting Back to Binary Values

Before storing numeric values in memory, you can reconvert back to binary values. To return a value i to a binary value, code:

i = D2C(i,4).