Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message

New User

Joined: 02 Mar 2007
Posts: 35
Location: Pennsylvania, US

 Posted: Thu Mar 15, 2007 2:46 pm    Post subject: How COMP and COMP-3 values are stored Hi, Can anyone tell me how COMP and COMP-3 values are stored? How storage bytes are calculated?

rammraju

New User

Joined: 05 Mar 2005
Posts: 65

 Posted: Thu Mar 15, 2007 3:12 pm    Post subject: Re: Clarify storage of COMP and COMP-3 Comp stores data in binary format. They occupy 2, 4, or 8 bytes of storage. If the PICTURE clause is signed, the leftmost bit is used as the sign. EX: A binary number with a PICTURE <=4 decimal digits occupies 2 bytes; 5 to 9 decimal digits occupies 4 bytes, 10 to 18 decimal digits occupies 8 bytes. Comp-3 stores data in Packed decimal format Packed-decimal items occupy 1 byte of storage for every 2 decimal digits you code in the PICTURE clause, except that the rightmost byte contains only one digit and the sign. Hope this is clear
naveen_amudalapelly
Warnings : 1

New User

Joined: 15 Oct 2004
Posts: 16

 Posted: Thu Mar 15, 2007 3:14 pm    Post subject: Re: Clarify storage of COMP and COMP-3 comp is a binary usage and while comp-3 is packed decimal. comp value stroes as binary and comp-3 store as hexa decimal format For example if your number is +100, it stores hex 0C in the last byte, hex 1C if your number is 101, hex 1D if the number is -101, hex 2D if the number is -102 etc
cooldebi

New User

Joined: 19 Apr 2006
Posts: 18
Location: mumbai

 Posted: Thu Mar 15, 2007 4:47 pm    Post subject: Re: Clarify storage of COMP and COMP-3 Storage is calculated as: let 01 WS-x PIC S9(x) usage is comp. let 01 WS-x PIC S9(x) usage is comp-3 for COMP --> no of bytes = x/2 (usually x is 2,4,8,16) for COMP-3 --> no of bytes = |(x/2+1/2)| as 1/2 is required for storing sign suppose u want to store 12 --> in a variable PIC 9(2) usage is comp. Internally it will be stored as 00001100 in 1 byte (binary representation). suppose u want to store 12 --> in a variable PIC 9(2) usage is comp-3. Internally it will be stored as 0001 0010 [quote]1111 0000 (Hexadecimal representation)in 2 bytes. underlined characters represents the sign nibble for comp-3.. 1111 cheers

New User

Joined: 02 Mar 2007
Posts: 35
Location: Pennsylvania, US

 Posted: Fri Mar 16, 2007 1:13 pm    Post subject: Re: How COMP and COMP-3 values are stored Thanks a lot friends...
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics LOW VALUES as a KEY juares castro DB2 10 Sat Apr 07, 2018 1:06 am Query to compare 2 values of 1 column... Poha Eater DB2 13 Fri Mar 09, 2018 10:45 am attchmvs from rexx subroutine that re... harisukumaran CLIST & REXX 1 Fri Jan 19, 2018 5:29 am COMP Variables Mismatch gayu7 COBOL Programming 5 Wed Dec 20, 2017 5:06 pm CICS web service from DB2 Triggers or... kiranprasad DB2 2 Wed Dec 20, 2017 11:10 am

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us