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
 

 

Can we add comp-3 vairable with Comp-5 variable

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

New User


Joined: 21 Jan 2006
Posts: 48
Location: india

PostPosted: Mon Aug 20, 2007 10:23 am    Post subject: Can we add comp-3 vairable with Comp-5 variable
Reply with quote

Hi All,
Can we add comp-3 vairable with Comp-5 variable without getting any compile/run time error.
Back to top
View user's profile Send private message

agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Mon Aug 20, 2007 12:05 pm    Post subject:
Reply with quote

What was the result when you tried it..?
Back to top
View user's profile Send private message
dr_te_z

New User


Joined: 08 Jun 2007
Posts: 71
Location: Zoetermeer, the Netherlands

PostPosted: Mon Aug 20, 2007 2:06 pm    Post subject:
Reply with quote

YES! That's the beauty of COBOL.
Back to top
View user's profile Send private message
noorkh

New User


Joined: 06 Mar 2006
Posts: 76
Location: Chennai

PostPosted: Mon Aug 20, 2007 6:04 pm    Post subject:
Reply with quote

Hopefully you can do. Because as a storage both works in Hexadecimal.
Back to top
View user's profile Send private message
kanak

Moderator


Joined: 12 Mar 2005
Posts: 252
Location: India

PostPosted: Wed Aug 22, 2007 2:32 pm    Post subject:
Reply with quote

I guess COMP-5 is same as comp-2 and adding comp-2 and comp-3...
Might can give some issuee under certain circumstance
Back to top
View user's profile Send private message
dr_te_z

New User


Joined: 08 Jun 2007
Posts: 71
Location: Zoetermeer, the Netherlands

PostPosted: Wed Aug 22, 2007 3:59 pm    Post subject:
Reply with quote

kanak wrote:
I guess COMP-5 is same as comp-2
Wrong guess.

COMP-5 stands for "binary native". On the mainframe this is not really an issue. On ohter platforms, however, there are processor architectures representing integers in a different way (http://en.wikipedia.org/wiki/Endianness). All those computers can run COBOL so sometimes the cobol compilers forces those binary-integers to behave in a standard way (comp-4). This might be sub-optimal for calculations. Specifiying COMP-5 allows native represention and optimal performance for calculations (comp-3 does not perform at all outside the mainframe!) .

So, when you want to produce portable code, always use comp-5 for your calculations.

I've also used this in the past to test at execution time to determine on which machine the program ran:
Code:
       01  Machinetest.
           03 binair-0000-0100-pic-X   pic X(2)  value X'0004'.
           03 which-endian             redefines
              binair-0000-0100-pic-X   pic S9(4) comp-5.

           03 B-I-G-endian value +0004 pic S9(4) comp-5.
           03 litle-endian value +1024 pic S9(4) comp-5.
       PROCEDURE DIVISION.
      ********************
       000-MAIN Section.
       000-010.
            evaluate which-endian
               when B-I-G-endian
                   display "this is the AIX (powerPC)"
               when litle-endian
                   display "this is a PC (intel inside!)"
               when other
                   display "how the *beep* do you run this program?"
            end-evaluate.

Those days I was coding & testing on windows (Micro Focus NetExpress) and the target machine was a R6000 (Micro Focus ServerExpress).
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 Can I traverse a STEM variable? chong.zhou CLIST & REXX 5 Wed May 31, 2017 3:54 pm
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm


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