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

Author Message
shammiullah

New User

Joined: 13 Jun 2005
Posts: 24

 Posted: Tue Jan 31, 2006 1:51 pm    Post subject: Storage occupation formula for COMP-3 hi guyz, 01 filed1 pic s9(3) comp-3. for this internally how many bytes will it take.do v have to use the formula n/2 + 1 or else n+1/2.if i'm using n/2 + 1 then it'll take 3 bytes. if i use the other formula it'll take 2 bytes. so which one shuld be used.

New User

Joined: 31 Jan 2006
Posts: 8
Location: Chennai

 Posted: Tue Jan 31, 2006 2:08 pm    Post subject: Hi , U need to use n/2 + 1
nuthan

Active User

Joined: 26 Sep 2005
Posts: 146
Location: Bangalore

 Posted: Tue Jan 31, 2006 3:25 pm    Post subject: Hi, If its even u have to use n/2 + 1 If its odd u have to use n+1/2
Hames

New User

Joined: 03 Oct 2005
Posts: 49

 Posted: Tue Jan 31, 2006 4:51 pm    Post subject: Hi nuthan, You have to use the formula n/2 + 1. If n is odd, you have to round the answer to the nearest integer. that is if n/2 + 1 = 2.5 then you round it to 3.
DavidatK

Active Member

Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

 Posted: Wed Feb 01, 2006 3:47 am    Post subject: Re: Storage occupation formula for COMP-3 shammiullah, Let?s start out with some truths. 1 - The compiler always allocates comp-3 fields in full bytes (unless you?re using a Burroughs computer that allocates in 1/2 bytes, I?ll bet most of you don?t even know what a Burroughs computer is! ) 2 - Each digit in the PIC occupies 1 half byte, or .5 full bytes 3 - The sign will occupy 1 half byte or .5 full bytes. (Even if it is unsigned, there is always a sign allocation) Example: PIC S9(3) COMP-3. PIC S9(3) COMP-3 will occupy 3 half bytes or 1.5 full bytes. The sign occupies 1 half byte or .5 full bytes. Therefore PIC S9(3) COMP-3 will occupy 2 full bytes. Another example: PIC 9(4) COMP-3 A PIC 9(4) COMP-3 will occupy 4 half bytes, or 2 full bytes. The sign (even when unsigned) will occupy 1 half byte, or .5 full bytes. The sum of these two is 5 half bytes, or 2.5 full bytes. Remember, the compiler always allocates in full bytes, therefore, the compiler will add 1 half byte, so PIC 9(4) will occupy 6 half bytes or 3 full bytes. You use the formula n/2 + ? rounded up to a full byte. n/2 = number of full bytes the digits from the PIC will use ? = the number of full bytes the sign will use rounded to full byte = number of full bytes the compiler adds to allocate in full bytes only. This will be 0, or .5 only Hope this helps, Dave
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics INSUFFICIENT VIRTUAL STORAGE!! Vignesh Sid SYNCSORT 1 Thu Dec 28, 2017 3:45 pm COMP Variables Mismatch gayu7 COBOL Programming 5 Wed Dec 20, 2017 5:06 pm Moving a COMP-3 Variable to a Numeric... ajayachander COBOL Programming 2 Thu Dec 14, 2017 5:46 pm CONDITIONAL USING COMP-2 WITH PROBLEMS. JOSUEGENTIL COBOL Programming 7 Wed Nov 08, 2017 11:13 pm how can i move s9(9) to s9(9) usage comp HARENDRA CHOUDHARY COBOL Programming 3 Mon Nov 06, 2017 12:10 am

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