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

Can we dynamically increase the size of occurs clause? i.e In case I an not sure of the size of array and want to increase the size at run time.If yes , how?

1 Answers  


Write a program to enter and display the names of students in a class using the occurs clause.

0 Answers  


is it possible to declare index in cobol program? if it is not why its tell me pls

3 Answers  


What is the maximum length of a field you can define using COMP-3?

4 Answers   Complex System, Infosys,


SIGN TRAILING SEPARATE field occupy ?

3 Answers  






How to use the same COBOL program in Batch and CICS on lines? explain with an example

0 Answers   IBM,


How are the next sentence and continue different from each other?

0 Answers  


How to delete leading spaces/blank in COBOL ? Example:- 01 data-name-1 pic x(220) " English is a language". I would like to delete leading spaces.

7 Answers   Financial Services,


What is the difference between a binary search and a sequential search?

3 Answers  


PERFORM ACCUMULATE-TOTALS VARYING A FROM 1 BY 2 UNTIL A >2 AFTER B FROM1 BY 1 UNTIL B>2 AFTER C FROM 2 BY -1 UNTIL C<2 How many times the paragraph ACCUMULATE-TOTALS would be exicuted?

5 Answers   TCS,


which is better either static call or dynamic call? and why?

5 Answers   HCL,


When search all is used in cobol program without sorted input data?

6 Answers   CGI, Principal Finance,


Categories