DTOB
Convert decimal data to binary values
WTSupported in traditional Synergy on Windows
|
|
USupported on UNIX
|
VSupported on OpenVMS
|
The DTOB routine is deprecated; we recommend you use the Integer data type or the %INTEGER function instead. |
xcall DTOB(decimal, binary)
Arguments
decimal
A field that contains the decimal value to be converted. (n)
binary
The variable that will be loaded with the converted decimal value in binary form. (a or n)
Discussion
The DTOB subroutine, like its counterpart the deprecated BTOD subroutine, simplifies manipulation of binary bytes (8 bits), words (16 bits), longwords (32 bits), and quadwords (64 bits). DTOB converts Synergy DBL decimal data to binary values, while BTOD does the converse.
Upon entry, many non-Synergy DBL subroutines and library routines require binary bytes, words, or longwords to be passed by reference. Because all data in Synergy DBL is in ASCII format and is manipulated by descriptor, you can either use integer data fields or the DTOB and BTOD routines to convert to and from binary and decimal data.
Quadwords (64 bits) are supported only on 64-bit machines. |
The DTOB routine converts a signed Synergy DBL decimal field to a binary value. The decimal value is obtained from a Synergy DBL expression (variable, literal, computation, and so forth), and the binary value is placed in an alpha or decimal, Synergy DBL-named field. Note how the following conditions affect DTOB:
- If the destination field (binary) is a1 or d1, DTOB performs a byte conversion and yields the same result as the ASCII subroutine.
- If binary is a2 or d2, DTOB performs a word conversion.
- If binary is a4 or d4, DTOB performs a longword conversion.
- If binary is a8 or d8, DTOB performs a quadword conversion.
- If binary is anything other than one, two, or four bytes, it is treated as though it were only one byte, and no error occurs.
Examples
If you enter the following data:
fld1 ,a1 fld2 ,a2 fld4 ,a4 fld5 ,a5 fld6 ,d6
the statements below perform these results:
xcall dtob(-1, fld5) ;Yields %XFFFFFFFFFF in fld5 (equiv. to ^i(fld5)=-1) xcall dtob(255, fld4) ;Yields %X000000FF in fld4 (equiv. to ^i(fld4)=255) xcall btod(fld5, fld6) ;Yields fld6 = -1 (equiv. to ^d(fld6)=^i(fld5)) xcall btod(fld4, fld2) ;Yields fld2 = "255" (equiv. to ^d(fld2)=^i(fld4))