View previous topic :: View next topic
|
Author |
Message |
pingte
Active User
Joined: 03 Dec 2005 Posts: 120 Location: india
|
|
|
|
Hi,
Why is length declared as COMP is most cases?
e.g. S9(4) COMP
Why is it not any other member of COMP family? |
|
Back to top |
|
|
devidas-patil
New User
Joined: 08 Jan 2007 Posts: 54 Location: pune
|
|
|
|
i guess S9(4) comp will take 2 bytes and most of the times for storing length of message in cics, null indicator we use s9(4) comp. thats why. and another thing if we use s9(5) then un-neccesarily it will take 4 byte and is we use usage. alos it help in case of Comp sync that why
please let me know if i a mwrong so that i can update to myself. |
|
Back to top |
|
|
pingte
Active User
Joined: 03 Dec 2005 Posts: 120 Location: india
|
|
|
|
My question is why we use COMP in particular for length..
why not COMP1,COMP2 or COMP3? |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
I guess You mean 'length' in
Linkage section when we pass parameters through
OR
length of record in RDW
There is no explanation for this- system is designed to work with binary numbers (COMP) in those cases.
If you meant anything else then please elaborate. |
|
Back to top |
|
|
pingte
Active User
Joined: 03 Dec 2005 Posts: 120 Location: india
|
|
|
|
thanks abhijit...
i have one more doubt...
Why do u use COMP for null indicators... is it the same reason.. that system underastands Binary?
If we had used HEX (COMP-3)what would have have been the problem?
b'coz in HEX also we can indicate +ve / -ve values...
or this is also related to system design?
Can u please xplain? |
|
Back to top |
|
|
socker_dad
Active User
Joined: 05 Dec 2006 Posts: 177 Location: Seattle, WA
|
|
|
|
If I understand you correctly, you simply want to know why we use COMP fields at all?
The simple answer is: to save storage.
Back when mainframes were new, storage was extremely expensive (and programmers were comparativley very cheap). So we developed was to cram as much information into as little space as possible - hence the COMP numeric fields.
That's the short answer. To understand why we use COMP, COMP1, COMP2 and COMP3, you have to look at the differences between them. For example, if I wanted to save space and didn't have to worry about whether the number was positive or negative - in the case of a table index for example - I woud use a COMP field. For other reasons to use the other types of COMP field, check out the programming manuals link at the top of the page. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
I hate to break this to you, but the COMP or COMP5 & 4?) are all valid binary. COMP1 & 2 are floating point and would never be used. Binary is used for length because the usual application for a length field is addition to an address and that is register math. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
pingte wrote: |
Why do u use COMP for null indicators... is it the same reason.. that system underastands Binary?
If we had used HEX (COMP-3)what would have have been the problem?
b'coz in HEX also we can indicate +ve / -ve values...
or this is also related to system design? |
Ok, I'll go look it up, I do need a little better understanding of null indicators.....
Be back shortly..... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
COMP fields are used in the situations you mentioned because IBM implemented as such. If you look at assembler code, you will see that many (nearly all) assembler instructions and system control blocks use 1, 2, and 4-byte binary fields as length, displacement, and incremental values. A 1-byte binary field is also a way to store 8 on/off switches in only 1 byte.
Most business code (quantities, rates, values, etc) are usually stored as comp-3 because the assembler business arithmetic instructions and editing require packed-decimal operands.
As s_d mentioned a big reason was to save space. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
pingte wrote: |
Why do u use COMP for null indicators... is it the same reason.. that system underastands Binary?
If we had used HEX (COMP-3)what would have have been the problem?
b'coz in HEX also we can indicate +ve / -ve values...
or this is also related to system design? |
OK, they could have used a simple one byte flag, but with the comp they allow for a two way decision, first, if negative, the result is a null (nothing exists in this column) value. Second, if -1 then it's a null, if -2 then it's null (nothing) because of errors.
And a word of advice, HEX and COMP-3 are not synonyms. HEX id eight bit representation for a character while COMP-3 is packed decimal and PD does not encompass all the potential HEX characters.
If you can't grok this, I suggest you open a new thread in the appropriate forum and ask that question.
BTW, what do you mean by "+ve / -ve values"? |
|
Back to top |
|
|
|