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

Author Message
hey_its_me
Warnings : 1

New User

Joined: 23 Aug 2006
Posts: 14
Location: USA

 Posted: Tue May 01, 2007 11:11 am    Post subject: Can s9(02) comp-3 contain a value 999? Hi all, I have a doubt regarding the packed decimal format of storage while using comp-3. I guess in comp-3 each byte contain 2 digits, and the last nibble is used to store sign. so here s9(02) comp-3 has (2/2+1) bytes = 2 bytes. so altogether, first byte would store a two digits and the next one with a sign. ie the maximum value it can store is 999. I'm confused on the maximum value s9(02) can store, is it 2 digits value eg: 99 or as explained above. Is this packed decimal concept only for storage, for better computation? Advise me and correct me if I'm wrong With Regards, Anil Kumar

Phrzby Phil

Active Member

Joined: 31 Oct 2006
Posts: 965
Location: Richmond, Virginia

 Posted: Tue May 01, 2007 5:27 pm    Post subject: COBOL restricts your values to your PIC, so +/-99 is the max value here. The leftmost nibble will always be zero. MOVE 123 to VAR will result in a value of 23. If you want the max according to your byte allocation, then use an odd number of digits.

New User

Joined: 05 Mar 2007
Posts: 5
Location: Chennai

 Posted: Mon May 28, 2007 3:09 pm    Post subject: S9(2) comp-3 & S9(3) comp-3 both will take only 2 bytes. But maximum value stored in first field is 99 and in seconde field is 999.
pcoreddy

New User

Joined: 14 Mar 2007
Posts: 24
Location: Mysore

 Posted: Mon May 28, 2007 4:17 pm    Post subject: Re: Can s9(02) comp-3 contain a value 999? S9(2) comp-3 & S9(3) comp-3 both will take only 2 bytes but both will store max 999 only... not 99
dick scherrer

Site Director

Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

Posted: Mon May 28, 2007 5:14 pm    Post subject:

Hello,

With which compiler options did you test this?
 Quote: but both will store max 999 only... not 99

Please post code of moving 999 to the 9(2) field and displaying that field after the move and the output from that test.
raam2smart

New User

Joined: 31 May 2007
Posts: 19
Location: Chennai

 Posted: Thu May 31, 2007 12:40 pm    Post subject: Re: Can s9(02) comp-3 contain a value 999? Hi i tried your example as such in a program, It gives 99 for s9(02) comp-3 & 999 for s9(03). The program is something like this: IDENTIFICATION DIVISION. PROGRAM-ID. JUNK. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-VAR1 PIC S9(02) COMP-3. 01 WS-VAR2 PIC S9(03) COMP-3. PROCEDURE DIVISION. MOVE 999 TO WS-VAR1. DISPLAY 'WS-VAR1 :' WS-VAR1. MOVE 999 TO WS-VAR2. DISPLAY 'WS-VAR2 :' WS-VAR2. STOP RUN. The output is: WS-VAR1 :99 WS-VAR2 :999 Thanks, Raam
donevin

New User

Joined: 07 Jun 2005
Posts: 70
Location: South Africa

 Posted: Thu May 31, 2007 4:56 pm    Post subject: If both declarations occupies 2 bytes and say half a byte is used to store a digit. What dictates that the Pic S9(02) comp-3 can only store 2 digits? Is it the digit 2 as opposed to 3 in the picture clause perhaps?
William Thompson

Global Moderator

Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

Posted: Thu May 31, 2007 5:13 pm    Post subject:

 donevin wrote: If both declarations occupies 2 bytes and say half a byte is used to store a digit. What dictates that the Pic S9(02) comp-3 can only store 2 digits? Is it the digit 2 as opposed to 3 in the picture clause perhaps?
Yes, if you specify 9(2), COBOL will add code to insure the leading half byte is always zero.
donevin

New User

Joined: 07 Jun 2005
Posts: 70
Location: South Africa

 Posted: Thu May 31, 2007 5:14 pm    Post subject: Thank you very much William.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm Need help to populate date in COMP-3 ... chetanambi DFSORT/ICETOOL 3 Tue Jun 21, 2016 12:25 pm comparing comp-3 and unpacked numbers juares castro COBOL Programming 3 Mon May 30, 2016 6:46 pm SIGNED DECIMAL TO COMP-3 using cobol ... ram_vizag COBOL Programming 1 Tue Mar 01, 2016 11:32 pm

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