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
 

 

How the comp-3 is stored in the system

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

New User


Joined: 31 May 2005
Posts: 11

PostPosted: Tue May 31, 2005 3:51 pm    Post subject: How the comp-3 is stored in the system
Reply with quote

hi,

i just want to know how the comp-3 is stored in the system and when it

is displayed how is it displayed.

Ex : 01 z pic s9(4) comp-3 value +1234.

how is it stored .....

and if given

display z.

how is it displayed

siva
Back to top
View user's profile Send private message

kanak

Moderator


Joined: 12 Mar 2005
Posts: 252
Location: India

PostPosted: Tue May 31, 2005 4:31 pm    Post subject:
Reply with quote

COMPUTATIONAL-3 or COMP-3 (internal decimal)
For VS COBOL II, this is the equivalent of PACKED-DECIMAL.

PACKED-DECIMAL
Specified for internal decimal items. Such an item appears in storage in packed decimal format. There are 2 digits for each character position, except for the trailing character position, which is occupied by the low-order digit and the sign. Such an item can contain any of the digits 0 through 9, plus a sign, representing a value not exceeding 18 decimal digits.
No idea how it get displayed.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Jun 01, 2005 8:37 am    Post subject:
Reply with quote

Hi siva,

It is converted to external decimal format (unpacked) before it is DISPLAYed.

Everthing looks normal except for the sign: it's diplayed using the low order 4 bits of the packed field as the high order 4 bits of the displayed byte and the low order digit of the packed field as the low order 4 bits of the diplayed byte.

E.g. X'011C' DISPLAYs as 01A (X'F0F1C1').
Back to top
View user's profile Send private message
Ashutosh Shrinet

New User


Joined: 22 Aug 2004
Posts: 10
Location: New Delhi

PostPosted: Wed Jun 01, 2005 8:46 am    Post subject: Re: comp-3 display
Reply with quote

hi siva
comp3 stored as packed decimal format.if u want to display it first u move this variable into another variable which's usage clause is display. then u can see the value of comp3.otherwise it will show in hexadecimal.
Back to top
View user's profile Send private message
senthilkumar selvaraju

New User


Joined: 30 May 2005
Posts: 16

PostPosted: Wed Jun 01, 2005 12:25 pm    Post subject:
Reply with quote

hi siva, Ashutosh Shrinet message is correct. as per your example it takes 3 bytes( n/2 + 1)

n- number of bytes (1234 i.e 4 bytes)

1 - for sign so (4/2 + 1) = 3 bytes (but i am not sure about odd bytes storage ) If any having answer please reply.........
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Fri Jun 03, 2005 4:35 am    Post subject:
Reply with quote

Hi Ashutosh,

You said:
Quote:
comp3 stored as packed decimal format.if u want to display it first u move this variable into another variable which's usage clause is display. then u can see the value of comp3.otherwise it will show in hexadecimal.

Have you ever tried to DISPLAY a COMP-3 field? You're in for a surprise.

The best way to formulate the size of a packed (COMP-3) field is to count the number of digit desired add 1 for the sign and divide by 2. BTW, there's ALWAYS a sign, even if you don't put one in the PIC.

If there's a remainder add 1 to answer. For example:
1234 is 4 digits; add 1 for the sign; divide by 2 = 2 1/2; add 1 to the 2 in the ans = 3 bytes.

12345 is 5 digits; add 1 for the sign; divide by 2 = 3; no remainder, no add 1; the ans = 3 bytes.
Back to top
View user's profile Send private message
mdtendulkar

Active User


Joined: 29 Jul 2003
Posts: 238
Location: USA

PostPosted: Sun Jun 05, 2005 2:28 am    Post subject:
Reply with quote

Jack,

We remember it this way

Quote:
For Even Digit Field formula is --> N /2 + 1
For Odd Digit Field formula is --> (N + 1)/2


icon_lol.gif

Regards
Mayuresh
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Jun 05, 2005 3:36 am    Post subject:
Reply with quote

Mayuresh,

But 1st, one must understand. icon_idea.gif
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Mon Jun 13, 2005 8:31 am    Post subject:
Reply with quote

Hi Mayuresh,

I should have added this to my previous post.

In my opinion the best way to calc the # of bytes in a comp-3 field is to total the # of 9s. If the total is even, divide by 2; if odd add 1 THEN divide by 2.

It eliminates playing w/the fraction and makes the division straightforward.
Back to top
View user's profile Send private message
mdtendulkar

Active User


Joined: 29 Jul 2003
Posts: 238
Location: USA

PostPosted: Mon Jun 13, 2005 4:15 pm    Post subject: Re: How the comp-3 is stored in the system
Reply with quote

Very True Jack,

Its the same formula which I showed.

EVEN 9's --> (N/2 + 1)
ODD 9's --> ((N+1)/2)

N = Number of 9's

icon_biggrin.gif

Regards,
Mayuresh
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Tue Jun 14, 2005 7:35 am    Post subject:
Reply with quote

No, Mayuresh. Mine was a sentence; YOUR'S was a formula. icon_wink.gif
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 Overlay the system date Danielle.Filteau SYNCSORT 4 Fri Mar 03, 2017 1:16 am
No new posts Query on DB2 WLM stored procedures ashek15 DB2 8 Sun Feb 12, 2017 11:13 pm
No new posts Is the 'prompt' data for the DSLIST p... Willy Jensen TSO/ISPF 2 Tue Dec 06, 2016 4:38 am
No new posts IMS BMP program causes 878 system abend Artemk IMS DB/DC 7 Tue Nov 22, 2016 8:26 pm
No new posts Check System time(Minute) Using TIME1... balaji81_k DFSORT/ICETOOL 5 Fri Nov 11, 2016 10:53 am


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