BTOD

Convert binary values to decimal data

WTSupported in traditional Synergy on Windows

 

USupported on UNIX
VSupported on OpenVMS
Note

The BTOD routine is deprecated; we recommend you use the Integer data type or the %ZONED function instead.

xcall BTOD(binary, decimal)

Arguments

binary

A field that contains the binary value to be converted. (a or n)

decimal

The variable that will be loaded with the destination of the converted binary value in decimal form. (d)

Discussion

The BTOD subroutine, like its counterpart the deprecated DTOB subroutine, supports manipulation of binary bytes (8 bits), words (16 bits), and longwords (32 bits).

BTOD converts a binary value into the appropriate ASCII string in a decimal field, while DTOB does the converse. If the field overflows, no error occurs. If the binary source is larger than four bytes, the rightmost four bytes are treated as a four-byte source. A one-byte source field yields the same result as the DECML subroutine.

Examples

If you define the following fields:

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))