Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
10Activity
0 of .
Results for:
No results containing your search query
P. 1
Comp-3 To Comp - Decimal Conversions

Comp-3 To Comp - Decimal Conversions

Ratings: (0)|Views: 1,311|Likes:
Published by sxdasgu

More info:

Published by: sxdasgu on Jan 21, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

05/08/2014

pdf

text

original

 
Comp-3 To Comp - DecimalConversions
Introduction:
A COBOL program involves the interaction of items with differentdata formats and the compiler converts these items eithertemporarily, for comparisons and arithmetic operations orpermanently, for assignment to the receiver in a MOVE or COMPUTEstatements.A conversion is simply a move of a value from one data item toanother data item.Compiler option TRUNC(STD), TRUNC(OPT) or TRUNC(BIN) can beused to indicate how binary data (BINARY, COMP, or COMP-4) getstruncated. Different examples given this document holds true
ONLY
for the compiler option
TRUNC(BIN).Aim of the document:
a)How the data is stored in the binary/COMP/COMP-3 packedfields?b)Behaviour of the COMP/COMP-3 packed fields when data istransferred across COMP/COMP-3 fields and other non-binaryfields.To elaborate more on the above mentioned points we will go throughfew of the examples given below:
Example 1:
 
Input Variable has datastored with the usage as COMP.
 
INPUTOUTPUTOBSERVATIONPICClauseValuepassedPICClauseValueReceived(Display)
S9(09)COMP12345678919(10)1234567891
ü
9(10)Comp-31234567891
ü
X(10)
234567891
?S9(10)
123456789A
?S9(10)Comp-31234567891
ü
S9(09)
23456789A
?
 
Points to be noted:Case 3
: In this case first integer gets truncated while moving fromS9 (09) COMP to X (10). Binary format (COMP) numbersoccupy 2, 4 or 8 bytes of storage and the leftmost bit isused as the operational sign. In this case ‘Sign’ isassociated with the first integer value i.e. ‘1’.There are 2 ways to get the correct value in the target field:
Use one intermediate variable of 9(10).S9 (09) COMP
à
9(10) and then9(10)
à
X (10)
Change the Picture clause of the source variable to S9(10) COMP. In this way ‘Sign’ gets freed up with the firstinteger value i.e.S9 (10) COMP
à
X (10)(=1234567891) (=1234567891)
Case 4 & 6
: In case 4, it is the display which is not showing thecorrect value but actually the correct value is storedinternally. In the decimal numeric type ‘Sign’ is alwaysassociated with the last byte.In case 6, first integer gets truncated because the target pictureclause is not big enough to accommodate the incomingdata.
Note:
Binary items with nine or more digits require more handlingby the compiler.
Example 2:
 
Input Variable has data stored with the usage asCOMP-3.
 
INPUTOUTPUTOBSERVATIONPICClauseValuepassedPICClauseValueReceived(Display)
S9(09)COMP-3123456789S9(09)
12345678I
?X(11)123456789
ü
S9(09)Comp-3123456789
ü
9(09)123456789
ü
Points to be noted:

Activity (10)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
ketaki.k14 liked this
DineshManivannan liked this
adityamahendru liked this
scarceboyz liked this
Mohan liked this
naveenmsn2 liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->