Re: COMP and COMP-3 fields

From: Harley (dennis.harleyNoSpam_at_worldnet.att.net)
Date: 05/29/04


Date: Sat, 29 May 2004 12:59:35 GMT

2 replies.

"Roger" <sudhakarkreddy@yahoo.com> wrote in message
news:a2380f6f.0405242135.13040b61@posting.google.com...
| Arnold Trembley <arnold.trembley@worldnet.att.net> wrote in message
news:<t1gsc.21673$fF3.557761@bgtnsc05-news.ops.worldnet.att.net>...
| > Roger wrote:
| > > Hi,
| > >
| > > I would like to know what is the maximum and minimum value that can be
| > > stored in the following declarations and how?
| > >
| > > 1. VAR1 PIC S9(03) COMP-3.
| > > 2. VAR2 PIC S9(04) COMP.
| > > 3. VAR3 PIC 9(03) COMP-3.
| > > 4. VAR4 PIC 9(04) COMP.
| > >
| > > It would be of great help, if anybody can answer to me on this.
| > >
| > > Thanks,
| > > Sudhakar
| >
| > Assuming IBM mainframe COBOL, which seems likely given the COMP-3,
| > which is usually IBM packed decimal, making COMP likely to be IBM
binary:

Comp-3 isn't exclusive to the IBM Mainframe, the Intel processors did, and
maybe still do support Packed Decimal.

| >
| > 1. Integer values from -999 through +999.
| > 2. Depends on the TRUNC compile-time option, but integer -9999
| > through +9999 for sure, possibly -32767 through +32767.
| > 3. Integer values from 000 through 999.
| > 4. Depends on the TRUNC compile-time option, but 0000 through 9999
| > for sure, possibly 00000 through 65535.

If you use COMP-5, the Compiler Option doesn't matter.

| >
| > My answer for #2 is debatable, due to two's complement of the lowest
| > negative number.
| >
| > I hope that helps!
|
| Thanks very much!!
|
| I still have few questions, in the program i am debugging it is right
| now able to store 18981 in the S9(04)comp field.
|
| So, can you please let me know how do i find out what should be the
| COMP declaration if i have to store a value of 45000....
|
| Also i heard that in S9(04) we can store a value of up to 65635
| eventhough we declared as s9(04) COMP....this is because COMP fields
| do not care the sign field if it is having positive value...

If you define the field as 9(4), the values range from 0 to 65635.
The S(ign) specification reduces the positive value by half, and allows
negative values.

If you really want to reduce the possibility of overflow use S9(8), or 9(8),
and COMP-5 if your compiler supports it.

|
| Please clarify...
|
| Thanks,
| Sudhakar



Relevant Pages

  • Re: COMP and COMP-3 fields
    ... >> stored in the following declarations and how? ... > Assuming IBM mainframe COBOL, which seems likely given the COMP-3, ... COMP declaration if i have to store a value of 45000.... ...
    (comp.lang.cobol)
  • Survey - "Most compilers" and USAGE COMP (was: Moving display to computational items
    ... Do you treat "COMP" as a BINARY format? ... - IBM mainframe - always big-endian ... - Micro Focus - dependent upon EBCDIC or ASCII character set or sign directives ...
    (comp.lang.cobol)
  • Re: FW: Mainframe Jobs Going Away
    ... I also visited the store on a fairly regular basis (New Brunswick NJ ... IBM Mainframe Discussion List ... For IBM-MAIN subscribe / signoff / archive access instructions, ... send email to listserv@xxxxxxxxxxx with the message: GET IBM-MAIN INFO ...
    (bit.listserv.ibm-main)