[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnubol: Extensions, documentation, and fixes for conversion routines



Jun 19, 2000  06:00


Folks,

I made several changes requested by Tim on the IBM Data Format
Conversion routines plus other fixes and extensions.  See list below.

I placed the gzip'ed tar file on my area on Compuserve.  My test data is
based on text books.  I'm not permitted to test stuff on the mainframe
at my place of employment (auditors can be a real pain).  If someone can
get some test data from an mainframe and run it through, it would
permitted better testing.

Routines are located at:

http://ourworld.compuserve.com/homepages/TSeward/transl~1.gz

Save under the name translate.tar.gz (I used an old upload program that
reduced the real name to 8.3 format).


Supplied Routines
-----------------

cnvAtoE -- Convert ASCII to EBCDIC

cnvBDtoL -- Convert IBM Binary Data to LONG

cnvDPtoD -- Convert IBM Double Precision floating point numbers (8 byte)
to ANSI C double format.

cnvDtoDP -- Convert double to IBM Double Precision Format (8 bytes).

cnvDtoSP -- Convert double to IBM Single Precision Format (4 bytes).

cnvEtoA -- Convert EBCDIC to ASCII.  EBCDIC has special entries not
found in ASCII (e.g. superscript numbers) and duplicates of some
characters (e.g. '{' & '}').  In these cases, the characters are
collapsed to their equivalent ASCII character.  If you translate all the
EBCDIC characters to ASCII and then back to EBCDIC again, the two areas
will not be identical in all cases.

cnvLtoBD -- Convert Long to IBM Binary Data (1, 2, 4, and 8 bytes)

cnvPDtoZD -- Convert IBM Packed Decimal numbers (1 to 16 bytes) to Zoned
Decimal.  The output is a null terminated string of digits with a
leading sign of + or -.  Upon successful conversion, the return code is
zero.  See The invalid return codes below.

cnvSPtoD -- Convert IBM Single Precision floating point numbers (4 byte)
to ANSI C double format.

cnvZDtoPD -- Convert Zoned Decimal number with leading sign to an IBM
Packed number (1 to 16).


Changes
-------

Extensive documentation was added to the top of the file translate.c.
Topics include cross-reference of COBOL data types and internal types.
Documentation on the IBM data types and their internal layouts.

Functions were added to convert Binary Data (1 to 8 bytes) to type long
and the conversion of type long to the Binary Data types.

All functions now supply an integer return code.  Where 0 indicates
success, and non zero a failure.  The header file includes constants for
the various return codes.  The routines that use to return type 'double'
as a return code now returns the value as an argument.

The packed conversion types now pass a length for both the zoned and
packed fields.  Flexibility was improved so leading zeros are not
counted when determining if a data item will fit into the destination
data type.

Conversion routines were added for both direction.  For example, there
is a routine to convert IBM Single Precision format to ANSI C double,
and a routine to convert ANSI C double to IBM Single Precision formats,
etc.

The routine transtest.c was adjusted for new types.

The Extended Precision logic was removed and placed in a set of routines
called transl.c.  The routines were not working very well and had less
accurate than the Double Precision logic.  I find no evidence that IBM
COBOL even supports the Extended Precision in the COBOL manuals:  COMP-1
is Single Precision and COMP-2 is Double Precision, but there is nothing
for Extended Precision.  See the table of cross-reference formats and
COBOL types at the top of translate.c.  The test driver for transl.c is
transltst.c, but again I do not recommend using them due to the poor
quality of the logic.

Good Luck - Ted Seward



--
This message was sent through the gnu-cobol mailing list.  To remove yourself
from this mailing list, send a message to majordomo@lusars.net with the
words "unsubscribe gnu-cobol" in the message body.  For more information on
the GNU COBOL project, send mail to gnu-cobol-owner@lusars.net.