Next: 4. Installation
Up: 3. Signed and binary
Previous: 3.4 Low-values, high-values and
Contents
Index
Subsections
To convert text data to and from binary, packed-decimal
and numeric data, six functions have been written
:
It converts text data to binary. The parameters of
the function are
- text is the text to convert.
- length is the length in bytes of binary
data. May only be 2, 4 or 8.
- signed is a flag to tell that the
binary item is signed. May only be "Y"
or "N".
If text data is signed and negative, then text data is
converted to binary and two's
complement is performed. Returned data is justified to the right and
padded with x'00' or x'FF' according to the sign. Finally, binary
data is reversed for little endian systems.
It converts text data to packed-decimal. The
parameters of the function are :
- text is the text to convert.
- length is the length in bytes of packed-decimal
data.
- signed is a flag to tell that the
packed-decimal item is signed. May only be
"Y" or "N".
If necessary, a leading zero is added to the packed-decimal
data so that the number of half-bytes is always odd. Returned data
is justified to the right and padded with x'00'.
It converts text data to numeric. The parameters of
the function are :
- text is the text to convert.
- length is the length in bytes of numeric
data.
- signed is a flag to tell that the
numeric item is signed. May only be "Y"
or "N".
- sign position is a flag to tell where
the sign is located. Allowed values are : '' (empty quotes - for
unsigned data), "L" (for LEADING sign), "T"
(for TRAILING sign), "LS" (for LEADING SEPARATE
sign) and "TS" (for TRAILING SEPARATE sign).
Non-numeric data, like $ or '.', is converted in
hexadecimal. Returned data is justified to the right and padded with
zeroes.
It converts binary data to text. The parameters of
the function are
- bin is the binary to convert.
- length is the length in bytes of binary
data. May only be 2, 4 or 8.
- signed is a flag to tell that the
binary item is signed. May only be "Y"
or "N".
Firstly, binary data is reversed for little
endian systems. If it is signed and negative, then two's
complement is performed before converting it to text. Leading zeroes
are removed and eventually the sign is added before returning
the text data.
It converts packed-decimal data to text. The
parameter of the function is :
- pack is the packed-decimal
data to convert.
Sign is extracted from the last half-byte of the packed-decimal.
Leading zeroes are removed and eventually the sign is added before
returning the text data.
It converts numeric data to text. The parameters of
the function are :
- num is the numeric data to convert.
- signed is a flag to tell that the
binary item is signed. May only be "Y"
or "N".
- sign position is a flag to tell where
the sign is located. Allowed values are : '' (empty quotes - for
unsigned data), "L" (for LEADING sign), "T"
(for TRAILING sign), "LS" (for LEADING SEPARATE
sign) and "TS" (for TRAILING SEPARATE sign).
Non-numeric data, like $ or '.', is converted from
hexadecimal to characters. Leading zeroes are removed and eventually
the sign is added before returning the text data.
Next: 4. Installation
Up: 3. Signed and binary
Previous: 3.4 Low-values, high-values and
Contents
Index
sunuraxi@users.sourceforge.net