Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Advantages of using comp-3 variables

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

New User


Joined: 02 Nov 2006
Posts: 22

PostPosted: Mon Dec 11, 2006 2:28 pm    Post subject: Advantages of using comp-3 variables
Reply with quote

Hi all,

Why exactly do we declare a variable as comp-3?

Is there any specific reason or advantage in doing so?

How can it serve the purpose if the variable is a counter variable?

Kindly clarify.

[/u]
Back to top
View user's profile Send private message

William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Mon Dec 11, 2006 3:20 pm    Post subject:
Reply with quote

Comp-3 is packed decimal, one of the mainframe native modes of arithmetic.
Declaring a variable as comp-3 (rather than display) allows arithmetic to be performed without conversation.
Actually, depending on what the counter is used for, comp might be more efficient.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 965
Location: Richmond, Virginia

PostPosted: Mon Dec 11, 2006 6:12 pm    Post subject:
Reply with quote

Whereas COMP may be more efficient than COMP-3, reading a COMP-3 value in hex is usually easier than reading COMP in hex. Human efficiency and ease may be more important than machine efficiency.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Dec 11, 2006 8:59 pm    Post subject:
Reply with quote

Hello,

Would you believe conversion<g>?
Quote:
Declaring a variable as comp-3 (rather than display) allows arithmetic to be performed without conversation.



Quote:
Whereas COMP may be more efficient than COMP-3, reading a COMP-3 value in hex is usually easier than reading COMP in hex. Human efficiency and ease may be more important than machine efficiency.


With the mainframe, comes a set of "packed decimal" instructions. These are designed for "business arithmetic" - calculating and showing edited things like quantities and dollars. To get a value to a zz,zzz,zz9.99- field, the underlying assembler will prepare the edited value by first staging the value to a packed-decimal field (if it is not already in packed decimal format), then "edit"ing it into the target field.

While comp may save a bit of storage, it often will not use less machine cycles (which few care about these days. . .).
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Mon Dec 11, 2006 9:28 pm    Post subject:
Reply with quote

dick scherrer wrote:
Would you believe conversion<g>?

icon_rolleyes.gif Grumble, grumble icon_rolleyes.gif
Dang spellchecker, do what I mean, not what I say!.....grin......
Back to top
View user's profile Send private message
cobolunni

Active User


Joined: 07 Aug 2006
Posts: 128
Location: kerala,india

PostPosted: Tue Dec 12, 2006 11:22 am    Post subject:
Reply with quote

Actually COMP 3 is used in case we had a signed number in comp3 each 2 digit will take 1 byte and the rightmost byte will contain only one digit plus the sign. So there is a reserved place for sign in COMP3 it will avoid the use of extra one byte for sign
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Tue Dec 12, 2006 3:35 pm    Post subject:
Reply with quote

cobolunni wrote:
there is a reserved place for sign in COMP3 it will avoid the use of extra one byte for sign

icon_lol.gif
COMP3 only needs an extra half byte for its sigh while COMP gets by with one bit.....
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Dec 12, 2006 11:54 pm    Post subject:
Reply with quote

Hmmmm. . . .


Quote:

COMP3 only needs an extra half byte for its sigh while COMP gets by with one bit...


Long sigh . . . . ?

Quote:


Grumble, grumble
Dang spellchecker, do what I mean, not what I say!.....grin......
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Tue Dec 12, 2006 11:59 pm    Post subject:
Reply with quote

dick scherrer wrote:
Long sigh . . . . ?
Well, they almost look the same....grin.... Heck with my fat fingers what do you expect icon_lol.gif

Quote:

Grumble, grumble
Dang spellchecker, do what I mean, not what I say!.....grin......
[/quote]
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 DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 8 Wed Jan 25, 2017 8:24 pm
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 0 Wed Jan 25, 2017 8:23 pm
No new posts DB2 9.1.0 not move values to Host-Var... Miguel Fernandez DB2 0 Wed Jan 25, 2017 8:21 pm
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us