0

What am I missing?

QualityPoints PIC 9v99 VALUE 4.00.
XValue        PIC 9v99 VALUE 3.00.
Total         PIC 999v99.
outTotal      PIC zz9V99.

COMPUTE Total = QualityPoints * XValue.
MOVE Total to outTotal.

When I perform this compute my outTotal is 11.2 what happened?

Please see the reproducable results using online compiler which has all my code and files available.

Simon Sobisch
  • 6,263
  • 1
  • 18
  • 38
CoryC
  • 11
  • 4
  • Which compiler and OS? Either the compile you are using is a bag'o'nuts or there is something causing this in code that you have not shown. If the program is large, try to reduce it to a small program which exhibits the problem. Sometimes, doing this, you'll find out why, as well. – Bill Woodger Sep 11 '16 at 06:26
  • using gnuopencobol on ubuntu not excatly sure which version I think its 14. I will try to get a better snippet as the code is around 200 lines long I didnt want to post up everything. I just knew that the values were 4.00 and 3.00 they come from an input and a check I displayed to make sure the values were correct before entering the compute and then bam math problem. – CoryC Sep 11 '16 at 07:55
  • 2
    Your actual data does not match the definition of your data. You have defined `Earned` as `9V99` but the data is held as `3.00` or `1.00`. You need to deal with that. One way is to define Earned as 9.99 (a numeric-edited field which would presume an actual decimal-point in the data) and MOVE that to an intermediate data-item defined as 9V99 and then use that intermediate item in the calculation. From memory @SimonSobisch already recommended that in an earlier question of yours. – Bill Woodger Sep 11 '16 at 09:21

1 Answers1

0

There is absolutely nothing wrong with your code other than the fact that it's not a complete program that you posted (no divisions or sections, no levels on your data, possibly other things that I couldn't be bothered testing)

Well, that and the fact that the link to the online compiler site has long since gone, proof once again that SO question should be completely self-contained with all information needed. When posting questions and answers, I always ask myself if they'll still be useful if the rest of the internet totally disappears.

However, using that same site, the following program(a) does work as expected:

IDENTIFICATION DIVISION.
PROGRAM-ID. PAX-DIABLO.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 QualityPoints PIC 9v99 VALUE 4.00.
01 XValue        PIC 9v99 VALUE 3.00.
01 Total         PIC 999v99.
01 outTotal      PIC zz9.99.

PROCEDURE DIVISION.
COMPUTE Total = QualityPoints * XValue.
MOVE Total to outTotal.
DISPLAY outTotal.
STOP RUN.

It produces the expected answer, as per the below transcript:

$cobc -x -free *.cobc -o main
$main
 12.00

(a) See, this answer is self-contained, see how easy that was :-)

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953