HP3000-L Archives

October 1997, Week 3

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Rick Brooks <[log in to unmask]>
Reply To:
Rick Brooks <[log in to unmask]>
Date:
Wed, 15 Oct 1997 13:55:49 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (37 lines)
Mike Berkowitz writes:

-----------------------------------------------------------------------
-------------
No, Tony is right.  Even though a COBOL PIC S9(9) COMP should only
hold to a maximum of 999,999,999, the compiler only uses your picture
clause as a blueprint for move and display statements.  Internally it
will
treat the number as a 32 bit signed integer that can have a maximum
value of (2 ** 31) - 1 or 2,147,483,647, unless you use an on size
error
clause.

Try the sample program:
 IDENTIFICATION DIVISION.
 PROGRAM-ID.  TST.
 DATA DIVISION.
 WORKING-STORAGE SECTION.
 77  A PIC S9(9) COMP.
 77  B PIC S9(18) COMP.
 PROCEDURE DIVISION.
 BEG-IT.
     COMPUTE A = (2 ** 31) - 1.
     MOVE A TO B.
     DISPLAY "A = " A.
     DISPLAY "B = " B.
     STOP RUN.

When you run it you will get:
A = +147483647
B = +000000002147483647

I humbly defer to the above description.  When I hit this problem, I
had to generate an unsigned  32 bit integer and write it in the same
format.  I had to accept my integer from my c routine in an x(4) field
and write it to the file as such.

ATOM RSS1 RSS2