Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Still COMP-5 2

Status
Not open for further replies.

fabiousa

MIS
Aug 13, 2001
45
BR

Thanks for the explanation on COMP-5.
I understand it's binary and everyithing else, but in real life, if I have FIELD PIC S9(18) COMP-5, what would be the maximum number I could store in FIELD?
Thanks again,

Fabio
 
Hi

You can store 18 digits plus a sign from
(+)999999999999999999 to - 999999999999999999 same ruls as in all cobol pictures.

//Renaldini
 
Actually....

Pic S9(18) COMP-5 SHOULD be invalid. The largest you can really store (given what a COMP-5 USUALLY means) is

S9(9) COMP-5 which is 4294967295 (Assuming a 32 bit environment and the traditional PC meaning for COMP-5)

If S9(18) is accepted, I would expect you could store:

A really big number... my calculator won't do it, but in hex it is:

X"FFFFFFFFFFFFFFFFFF"
 
Hi,

I don't agree with Thane.

PIC S9(18) COMP-5

is a valid definition. COMP-5 means native format, so it is the format that belongs to the hardware platform the compiler is running on.

On an IBM mainframe and on the PC (CA-REALIA), the S9(18) COMP-5 is 8 bytes long; this is a doubleword.

IBM says the following about this:

Code:
The table below shows the ranges of values possible for COMP-5 data items.    
                                                                              
                                                                              
  _________________ _____________________ ________________________________    
 | Picture         | Storage             | Numeric values                 |   
 |                 | representation      |                                |   
 |_________________|_____________________|________________________________|   
 | S9(1) through   | Binary halfword (2  | -32768 through +32767          |   
 | S9(4)           | bytes)              |                                |   
 |_________________|_____________________|________________________________|   
 | S9(5) through   | Binary fullword (4  | -2,147,483,648 through         |   
 | S9(9)           | bytes)              | +2,147,483,647                 |   
 |_________________|_____________________|________________________________|   
 | S9(10) through  | Binary doubleword   | -9,223,372,036,854,775,808     |   
 | S9(18)          | (8 bytes)           | through                        |   
 |                 |                     | +9,223,372,036,854,775,807     |   
 |_________________|_____________________|________________________________|   
 | 9(1) through    | Binary halfword (2  | 0 through 65535                |   
 | 9(4)            | bytes)              |                                |   
 |_________________|_____________________|________________________________|   
 | 9(5) through    | Binary fullword (4  | 0 through 4,294,967,295        |   
 | 9(9)            | bytes)              |                                |   
 |_________________|_____________________|________________________________|   
 | 9(10) through   | Binary doubleword   | 0 through                      |   
 | 9(18)           | (8 bytes)           | 18,446,744,073,709,551,615     |   
 |_________________|_____________________|________________________________|

It has everything to do with the amount of bits you use. This sign uses 1 bit.

I hope this is helpful.

Regards,

Crox
 
Thanks Crox,

That's almost the point - Comp-5 is implementor defined! Some compiler disallow anything over pic s9(9) comp-5 - (4 bytes) - obviously others do not!

 
Thanks a lot!
The table was everthing I needed :))

Fabio
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top