IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How can we store of -1234 as comp3 value


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
raju_rangam
Warnings : 1

New User


Joined: 31 Mar 2005
Posts: 25
Location: bangalore

PostPosted: Tue Dec 27, 2005 11:33 am
Reply with quote

how can we store of -1234comp3 value
Back to top
View user's profile Send private message
umeshkmrsh

New User


Joined: 21 Sep 2005
Posts: 79
Location: India

PostPosted: Tue Dec 27, 2005 2:35 pm
Reply with quote

Could you please explain the question.
Back to top
View user's profile Send private message
raju_rangam
Warnings : 1

New User


Joined: 31 Mar 2005
Posts: 25
Location: bangalore

PostPosted: Wed Dec 28, 2005 1:05 pm
Reply with quote

suppose some explanation on comp3, that how it stores internally
Back to top
View user's profile Send private message
anilbatta

New User


Joined: 13 Nov 2005
Posts: 22

PostPosted: Wed Dec 28, 2005 4:32 pm
Reply with quote

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
View user's profile Send private message
kumar_ngl
Warnings : 1

New User


Joined: 05 Aug 2005
Posts: 50
Location: chennai

PostPosted: Wed Dec 28, 2005 5:48 pm
Reply with quote

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

Active Member


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

PostPosted: Wed Dec 28, 2005 9:09 pm
Reply with quote

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
View user's profile Send private message
rajesh_1183

Active User


Joined: 24 Nov 2005
Posts: 121
Location: Tadepalligudem

PostPosted: Thu Dec 29, 2005 11:54 am
Reply with quote

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
View user's profile Send private message
mijanurit
Currently Banned

New User


Joined: 26 Aug 2005
Posts: 33
Location: bangalore

PostPosted: Sun Jan 08, 2006 10:13 am
Reply with quote

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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Mon Jan 09, 2006 4:13 am
Reply with quote

Hi mijanurit,

Quote:
024
13D


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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts SDSF like solution in EJES (store com... All Other Mainframe Topics 4
No new posts VSAM ESDS File to store large data 4GB JCL & VSAM 5
No new posts Need a Macro to compare datasets and ... All Other Mainframe Topics 2
No new posts Need an info to store Hexadecimal val... DB2 5
No new posts Move from Comp3 variable to Edited Va... COBOL Programming 7
Search our Forums:

Back to Top