There is a variable with value 19446. Requirement is to
convert it to 194.46. I tried it by doing divide by 100 and
my receiving field data type is 9(03)v99. But the output is
194. I am not getting the decimal value. Could anyone pls
let me know how to get this done?

Answers were Sorted based on User's Feedback



There is a variable with value 19446. Requirement is to convert it to 194.46. I tried it by doing ..

Answer / kiro

When COBOL does a divide it uses the format of the item
which in this case is integer only that is why the
fractional part is missing. You need to move the value
19446 to a 9(5)v99 item first and then do the divide using
the 9(5)v99 item.

Is This Answer Correct ?    7 Yes 0 No

There is a variable with value 19446. Requirement is to convert it to 194.46. I tried it by doing ..

Answer / vaneesh

To make this we require to use redefines.

01 ws-value-change
05 WS-ALPHANUMERIC PIC X(5).
05 WS-NUMERIC REDEFINES WS-ALPHANUMERIC PIC 9(3)
V99.
011 WS-EDITED-NUMERIC PIC 9(3).99.

PROCEDURE DIVISION

MOVE '19446' TO WS-ALPHANUMERIC
MOVE WS-NUMERIC TO WS-EDITED-NUMERIC
DISPLAY WS-EDITED-NUMERIC

STOP RUN

You will get the value as 194.46

Is This Answer Correct ?    7 Yes 0 No

Post New Answer

More COBOL Interview Questions

How to read a record from bottom of a file which is indexed by 'A'.

4 Answers   Oracle,


When is inspect verb is used in cobol?

0 Answers  


how can u redefine picx(10) with pic 9(6).

3 Answers   TCS,


what is the use of comp2 ? where can we use it with example ?

3 Answers   Covansys,


how can you identify wheather the program is using search or search all in the cobol program?

5 Answers   iGate,






How can you pass values from COBOL program to non-COBOL programs?

2 Answers  


should I use Go back in the main program ? Yes we can use Go back in main program as well.

2 Answers   Xansa,


The maximum number of dimensions that an array can have in COBOL-85 is ?

11 Answers  


If a file has 1000 records.. if i have to replace the first and last characters of the file with another character. how it can be done....

1 Answers   HCL,


How to fetch 1000 error records from VSAM file(Eg: 1000000 records present) while getting SOC7 abend ?

0 Answers  


What are various search techniques in cobol? Explain.

0 Answers  


Can printer files (having 133 characters) be of variable length?

3 Answers  


Categories