View previous topic :: View next topic
|
Author |
Message |
mambopras
New User
Joined: 11 Nov 2008 Posts: 52 Location: Hyderabad
|
|
|
|
Hi,
Oflate i got a small problem while handling a COMP-2 variable. I have an input file which has amount variable declared as COMP-2 and this has to be moved in one of the programs to an output copyboko variable which is X(30). But, this is not allowed....does any one know how can i move the COMP-2 , a double precision value, to X(30) without losing data or getting junk values. Thanks for ur help in advance!
Thanks and Regards,
Mambo! |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Code: |
05 VAR-1 COMP-2.
05 VAR-2 PIC 9(30).
05 VAR-2-R REDEFINES VAR-2
PIC X(30).
/
PROCEDURE DIVISION.
S1000-MAIN SECTION.
MOVE 123456789 TO VAR-1.
MOVE VAR-1 TO VAR-2.
DISPLAY 'VAR-1 ' VAR-1.
DISPLAY 'VAR 2 ' VAR-2-R. |
prodcues results of
Code: |
VAR-1 .12345678900000000E 09
VAR 2 000000000000000000000123456789 |
For error processing, handling data values that are too large for the output field is recommended. |
|
Back to top |
|
|
mambopras
New User
Joined: 11 Nov 2008 Posts: 52 Location: Hyderabad
|
|
|
|
Thanks a lot Robert....the solution worked though i can't use 9(30). The maximum i could declare was 9(18). So i did that and the results were satisfactory for me. But the main idea was yours...thanks a lot! |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
the solution worked though i can't use 9(30). The maximum i could declare was 9(18). |
Compiler option ARITH(EXTEND) extends the maximum digits from 18 to 31; this is not the default. This works on the Enterprise COBOL compilers; I'm not sure how far back it goes.
But I'm glad you got it working. |
|
Back to top |
|
|
mambopras
New User
Joined: 11 Nov 2008 Posts: 52 Location: Hyderabad
|
|
|
|
thanks for that |
|
Back to top |
|
|
|