View previous topic :: View next topic
|
Author |
Message |
jackal Currently Banned New User
Joined: 21 Jan 2006 Posts: 48 Location: india
|
|
|
|
Hi All,
Can we add comp-3 vairable with Comp-5 variable without getting any compile/run time error. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
What was the result when you tried it..? |
|
Back to top |
|
|
dr_te_z
New User
Joined: 08 Jun 2007 Posts: 71 Location: Zoetermeer, the Netherlands
|
|
|
|
YES! That's the beauty of COBOL. |
|
Back to top |
|
|
noorkh
New User
Joined: 06 Mar 2006 Posts: 76 Location: Chennai
|
|
|
|
Hopefully you can do. Because as a storage both works in Hexadecimal. |
|
Back to top |
|
|
kanak
Moderator
Joined: 12 Mar 2005 Posts: 252 Location: India
|
|
|
|
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 |
|
|
dr_te_z
New User
Joined: 08 Jun 2007 Posts: 71 Location: Zoetermeer, the Netherlands
|
|
|
|
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 |
|
|
|