next up previous contents index
Next: 4. Installation Up: 3. Signed and binary Previous: 3.4 Low-values, high-values and   Contents   Index

Subsections

3.5 Functions

To convert text data to and from binary, packed-decimal and numeric data, six functions have been written :

txt2bin

It converts text data to binary. The parameters of the function are

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.

txt2pack

It converts text data to packed-decimal. The parameters of the function are :

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'.

txt2num

It converts text data to numeric. The parameters of the function are :

Non-numeric data, like $ or '.', is converted in hexadecimal. Returned data is justified to the right and padded with zeroes.

bin2txt

It converts binary data to text. The parameters of the function are

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.

pack2txt

It converts packed-decimal data to text. The parameter of the function is :

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.

num2txt

It converts numeric data to text. The parameters of the function are :

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 up previous contents index
Next: 4. Installation Up: 3. Signed and binary Previous: 3.4 Low-values, high-values and   Contents   Index
sunuraxi@users.sourceforge.net