Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Storage occupation formula for COMP-3

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
shammiullah

New User


Joined: 13 Jun 2005
Posts: 24

PostPosted: Tue Jan 31, 2006 1:51 pm    Post subject: Storage occupation formula for COMP-3
Reply with quote

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.
Back to top
View user's profile Send private message

madhavihmk

New User


Joined: 31 Jan 2006
Posts: 8
Location: Chennai

PostPosted: Tue Jan 31, 2006 2:08 pm    Post subject:
Reply with quote

Hi ,

U need to use n/2 + 1
Back to top
View user's profile Send private message
nuthan

Active User


Joined: 26 Sep 2005
Posts: 146
Location: Bangalore

PostPosted: Tue Jan 31, 2006 3:25 pm    Post subject:
Reply with quote

Hi,

If its even u have to use n/2 + 1

If its odd u have to use n+1/2
Back to top
View user's profile Send private message
Hames

New User


Joined: 03 Oct 2005
Posts: 49

PostPosted: Tue Jan 31, 2006 4:51 pm    Post subject:
Reply with quote

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.
Back to top
View user's profile Send private message
DavidatK

Active Member


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

PostPosted: Wed Feb 01, 2006 3:47 am    Post subject: Re: Storage occupation formula for COMP-3
Reply with quote

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! icon_wink.gif )
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
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts GETMAIN / FREEMAIN versus STORAGE OBT... steve-myers PL/I & Assembler 8 Wed Feb 01, 2017 1:45 am
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm
No new posts Need help to populate date in COMP-3 ... chetanambi DFSORT/ICETOOL 3 Tue Jun 21, 2016 12:25 pm
No new posts comparing comp-3 and unpacked numbers juares castro COBOL Programming 3 Mon May 30, 2016 6:46 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us