View previous topic :: View next topic
|
Author |
Message |
cobolunni
Active User
Joined: 07 Aug 2006 Posts: 127 Location: kerala,india
|
|
|
|
01 TAB.
02 A PIC S9(11) USAGE IS COMP
02 B PIC S9(11) USAGE IS COMP SYNC
02 C USAGE IS INDEX
02 D USAGE IS POINTER
02 E PIC 9(11) USAGE IS COMP-3
PLEASE TELL THE SIZE OF TAB |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
Quote: |
01 TAB.
02 A PIC S9(11) USAGE IS COMP
02 B PIC S9(11) USAGE IS COMP SYNC
02 C USAGE IS INDEX
02 D USAGE IS POINTER
02 E PIC 9(11) USAGE IS COMP-3
PLEASE TELL THE SIZE OF TAB
|
The length of TAB is 30.
A = 8
B = 8
C = 4
D = 4
E = 6
Total = 30
Dave |
|
Back to top |
|
|
cobolunni
Active User
Joined: 07 Aug 2006 Posts: 127 Location: kerala,india
|
|
|
|
david can u please explain it for me |
|
Back to top |
|
|
Archana_MF
New User
Joined: 21 Jul 2006 Posts: 49 Location: California
|
|
|
|
Below is a brief Desc of each Usage.
02 A PIC S9(11) USAGE IS COMP : This is Binary and the memory is defined as 2's complement numbers (2x) i.e 2, 4, 8, 16 etc etc
So for PIC 1-4 : 2 bytes
PIC 5-9 : 4 Bytes
PIC 10-18: 8 Bytes
and this is byte aligned. For Ur Ex it is 8 Bytes
02 B PIC S9(11) USAGE IS COMP SYNC : Similar to COMP but is synchronized to Word Boundaries. 8-Bytes
02 C USAGE IS INDEX : This is a 4-byte data-item to which the Index value is stored for refrences like table occurances and it need not be a part of the table. the Index data-item can be directly ref by SERACH/SET/COND.
02 D USAGE IS POINTER : This is a 4-Byte field to store address of any data-item or field. when u use this field in ur program ur actually using the address in it which in turn points to actual data.
02 E PIC 9(11) USAGE IS COMP-3 <== It uses a notation called BCD(Binary Coded Decimal) i.e two digits are stored in 1 byte (8 bits ) or u can say 1 digit in 4 bits(nybble). To calculate the storage add 1 to the number of PIC bytes and divide by 2. here it is (11+1)/2 i.e 6 bytes
for Ex a number 12345678901(11 digits) is stored as 12 34 56 78 90 1C , C is sign stored in the last Nybble.
Hope this helps |
|
Back to top |
|
|
MKP
New User
Joined: 23 Aug 2006 Posts: 12 Location: Chennai
|
|
|
|
Hi Archana,
If a group size is 12 , Now i am using comp-3 as an usage clause. will it take 6.5 bytes or 7 bytes. |
|
Back to top |
|
|
Archana_MF
New User
Joined: 21 Jul 2006 Posts: 49 Location: California
|
|
|
|
It will be rounded to 7 Bytes for PIC (12) Comp-3 and the upper 4 bits will be ignored and can be zeroes . |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi MKP,
For declaration
02 E PIC 9(12) USAGE IS COMP-3
It will take 6 Bytes
02 E PIC S9(12) USAGE IS COMP-3
It will take 7 bytes. |
|
Back to top |
|
|
Archana_MF
New User
Joined: 21 Jul 2006 Posts: 49 Location: California
|
|
|
|
Correct me If I am wrong,
I thought COMP-3 will reserve a Nibble for sign irrespective of
Signed S9(12) / Unsigned 9(12) values, making it always 7 bytes for this ex. |
|
Back to top |
|
|
MKP
New User
Joined: 23 Aug 2006 Posts: 12 Location: Chennai
|
|
|
|
Hi Guptae,
Ru sure that if i wont specify s9(12) instead of 9(12) it iwll take only 6 bytes. |
|
Back to top |
|
|
kondakonda
New User
Joined: 20 Mar 2006 Posts: 34
|
|
|
|
Hi,
I am sure it will occupy 7 bytes irrespective of 9(12) or s9(12)
Thanks. |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
02 E PIC 9(11) USAGE IS COMP-3
It will take 6 Bytes
02 E PIC S9(11) USAGE IS COMP-3
It will take 6 Bytes
02 E PIC 9(12) USAGE IS COMP-3
It will take 7 Bytes
02 E PIC S9(12) USAGE IS COMP-3
yeap it will occupie seven byte |
|
Back to top |
|
|
cobolunni
Active User
Joined: 07 Aug 2006 Posts: 127 Location: kerala,india
|
|
|
|
In case i have given a sync clause in a group item is that clause applicable to all the members of the group or only for that item |
|
Back to top |
|
|
jose.jeyan
New User
Joined: 28 Jul 2006 Posts: 60 Location: Mumbai
|
|
|
|
for 02 E PIC 9(12) USAGE IS COMP-3
it will take 6 bytes as sign is not specified
for 02 E PIC s9(12) USAGE IS COMP-3
it will take 7 bytes as the genral formula is int((n/2)+1),sign is stored as hex value in the last nibble. |
|
Back to top |
|
|
cobolunni
Active User
Joined: 07 Aug 2006 Posts: 127 Location: kerala,india
|
|
|
|
Please tell me What is the default word boundary in minframe |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
jose.jeyan,
Quote: |
for 02 E PIC 9(12) USAGE IS COMP-3
it will take 6 bytes as sign is not specified |
Wrong!
Each number occupies half a byte. The rightmost half-byte contains the sign:
C if it's positive,
D if it's negative,
F if it's unsigned.
If you specify an even number (multiple of 2), the leftmost half-byte will contain 0 and will be "wasted".
That's why it is of good practice to specify an odd number (not multiple of 2) for the size of COMP-3 fields, as the fine book says. |
|
Back to top |
|
|
jose.jeyan
New User
Joined: 28 Jul 2006 Posts: 60 Location: Mumbai
|
|
|
|
thanks marso |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Let's change cobolunni's ques.
Reverse all the 02 level variables in 01 TAB (i.e. E D C B A, instead of A B C D E).
Now, what will the size of TAB be? |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
Tab starts on a word boundary (Multiple of 4 bytes)
Code: |
Offset
from
?TAB? Variable Length
0 E 6
6 D 4
10 C 4
14 slack 2 (added to word align B)
16 B (sync) 8
24 A 8
Total Length 32
|
Dave |
|
Back to top |
|
|
cobolunni
Active User
Joined: 07 Aug 2006 Posts: 127 Location: kerala,india
|
|
|
|
In the group (in my first question ) There is a SYNC in the data name B .B is in the group called tab . B has a size of 8 bytes SYNC will create a word boundary of 8 .Is this word boundary is applicable to all of the members in the group .Is that the condition then the answer of my first question will be 40 instead of 30 . Please tell me if SYNC clause is apllicable to all of the members in the group or not |
|
Back to top |
|
|
|