Thursday, November 16, 2006

Review: COBOL: Rounding and mathematical statements

I took both parts of the Brainbench COBOL II refresher Beta Test Thurs Nov 16 and scored in the 61-st percentile and then 93rd.

Consider this statement:

This is an old-fashioned way to code, and the result is stored in FIELD2. It is not rounded unless ROUNDED is specified. ON SIZE ERROR can specify a routine to perform if the picture clause for the receiving field is exceeded.

You can specify a REMAINDER clause on division (just as in grade school arithmetic), or use a REM function.

The COMPUTE statement usually makes code more readable, with parentheses. But you should know the order of operations (or order of precedence), which is the sames as in Algebra I ! This commonly is tested on multiple-choice quizzes.

Operations are performed from left to right. Exponentiation is done first. Then go back and do multiplications and divisions. Finally do additions and subtractions.

No comments: