View previous topic :: View next topic
|
Author |
Message |
raju_rangam Warnings : 1 New User
Joined: 31 Mar 2005 Posts: 25 Location: bangalore
|
|
|
|
how can we store of -1234comp3 value |
|
Back to top |
|
|
umeshkmrsh
New User
Joined: 21 Sep 2005 Posts: 79 Location: India
|
|
|
|
Could you please explain the question. |
|
Back to top |
|
|
raju_rangam Warnings : 1 New User
Joined: 31 Mar 2005 Posts: 25 Location: bangalore
|
|
|
|
suppose some explanation on comp3, that how it stores internally |
|
Back to top |
|
|
anilbatta
New User
Joined: 13 Nov 2005 Posts: 22
|
|
|
|
Hi Raju,
Please elaborate the question and my sincere advice is to explain your problem clearly.
I will explain the concept of COMP-3 in detailed manner. COMP-3 will be in Hexadecimal format and stores the values according to that.
Formaula for calculating the COMP-3 value is:
Example: 01 A
02 B PIC S(9) COMP-3
EXPLANATION:
The no of digits that the value will be stored is 6, because the formaula for this is (n/2)+1 exclusively for COMP-3. The result will be 4.5+1, so in this case, the final result is 5 bcoz it will consider the nearest digit value. I hope this example will be helful for you. |
|
Back to top |
|
|
kumar_ngl Warnings : 1 New User
Joined: 05 Aug 2005 Posts: 50 Location: chennai
|
|
|
|
hi raju,
Usually in COMP-3 , 1 word is equal to 1/2 byte ..so in ur example its 2 bytes of 1234 and another 1/2 byte for (-)..so totally 3 bytes. this (-) will be stored in the right most area.
1 3 -
2 4
kumar.p.v |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
Quote: |
how can we store of -1234comp3 value
|
Two examples of COMP-3.
Code: |
05 A PIC S9(4) COMP-3.
05 B PIC 9(4) COMP-3.
MOVE -1234 TO A.
MOVE -1234 TO B.
|
The move to 'A' results a hex value in 'A' of:
024
13D
And the move to 'B' results in a hex value of :
024
13F
For both of these, the sign is in the right most half byte.
In 'A', because it's a signed field you can get a 'C' = '+' and a 'D' = '-' in the sign half byte. In 'B', because it's unsigned, you loss the sign when you move to the field and the sign will always be 'F' = unsigned. |
|
Back to top |
|
|
rajesh_1183
Active User
Joined: 24 Nov 2005 Posts: 121 Location: Tadepalligudem
|
|
|
|
For Comp-3 variables sign will be stored in the last nibble(4 bytes)
last nible will contain..
C - if it is a signed positive
D - if it is a signed negative
F - if it is unsigned
Rajesh |
|
Back to top |
|
|
mijanurit Currently Banned New User
Joined: 26 Aug 2005 Posts: 33 Location: bangalore
|
|
|
|
hi davidakt,
would u plz to explain ur example in details.
05 A PIC S9(4) COMP-3.
05 B PIC 9(4) COMP-3.
MOVE -1234 TO A.
MOVE -1234 TO B.
The move to 'A' results a hex value in 'A' of:
024
13D
And the move to 'B' results in a hex value of :
024
13F
i am not getting how value stored in A,
024
13d
actually problem with digit sequence.
i am thinking about
012
34D
plz explain.
thanks and regards
mijanurit |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi mijanurit,
This is a variation of the way hex values are displayed in ISPF. They're read top to bot, left to right. Each column represents 1 EBCDIC char.
An alternative is X'01234D', something similar to what you mentioned. |
|
Back to top |
|
|
|