Decimal arithmetic

ADD, SUBTRACT, MULTIPLY, DIVIDE and COMPUTE, and then the digits a plain statement throws away against the ones ROUNDED keeps. ON SIZE ERROR, intermediate precision and a running total in a loop follow. The part closes on why money is decimal and on a wrong total that is traced and fixed.

023 ADD and SUBTRACT TO, FROM, GIVING, several operands at once, and the sign of the result Open 024 MULTIPLY and DIVIDE BY, GIVING, REMAINDER, DIVIDE INTO, and a division that does not fit Open 025 COMPUTE and arithmetic expressions **, unary minus, precedence, and one COMPUTE against several separate verbs Open 026 ROUNDED and truncation the digits a plain statement throws away, ROUNDED, and the half-up rule of COBOL Open 027 ON SIZE ERROR a receiving field too small, what the statement did to the field, NOT ON SIZE ERROR Open 028 Intermediate precision the temporary field the compiler uses, why COMPUTE beats a chain of MOVEs, and -W truncation Open 029 Why money is decimal COMP-3 against a binary float, the cent a float loses, and the same sum in both Open 030 Arithmetic in a loop a running total under PERFORM VARYING, rounding once at the end, and the total checked by hand Open 031 Edited numeric output Z, the comma, the decimal point, CR and DB, the currency sign, and a printed amount Open 032 An arithmetic bug, found and fixed a wrong total, the truncation that caused it, the fix, and the check that proves the fix Open

Lessons