COBOL: How to MOVE Comp-3 to Numeric

COBOL comp variables speed up your execution time and save your storage space. Numerical calculations need your skill in dealing with COBOL comp-3 variables. The example below helps you how to use the Comp-3 variables in your COBOL program.

How to MOVE comp-3 value to Numeric in COBOL

Let us take an example and I will explain how to write code for this.

01 Var-1 s9(3) comp-3 value 123.
01 Var-2 s9(3) value 0.

Instead of MOVE statement use ‘ADD’. So that you will get correct result.

ADD VAR-1 to VAR-2

Now, you will get data in numeric format i.e into VAR-2.

Related Posts

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.