Radix
Radix

Reputation: 69

convert comp-2 to alphanumeric in cobol

I have a copybook with several COMP-2 variables that I need in alphanumeric form for DISPLAY purposes. I have tried MOVE, REDEFINES, MOVE to numeric then to alphanumeric and nothing seems to work.

Upvotes: 0

Views: 1182

Answers (1)

Bill Woodger
Bill Woodger

Reputation: 13076

Here's a program:

   ID DIVISION. 
   PROGRAM-ID DISPLEXP. 
   DATA DIVISION. 
   WORKING-STORAGE SECTION. 
   01  SOME-NAME                    COMP-2. 
   01  SOME-OUTPUT                         PIC -9.9E-99.
   PROCEDURE DIVISION. 
       MOVE -2.3E-6                 TO SOME-NAME 
                                       SOME-OUTPUT 
       DISPLAY 
               ">" 
               SOME-NAME 
               "<" 
               ">" 
               SOME-OUTPUT 
               "<" 
       GOBACK 
       . 

The output is:

>-.23000000000000000E-05<>-2.3E-06<

If you can clarify your question, I'm sure there's an answer available.

Upvotes: 3

Related Questions