## REBOL for COBOL programmers |

## ROUNDED
## COBOL ROUNDEDThe various COBOL arithmentic operators have the optional ROUNDED clause. For example, DIVIDE { identifier-1 } INTO { identifier-2 } GIVING identifier-3 [ROUNDED] REMAINDER identifier-4. { literal-1 } { literal-2 } COMPUTE identifier-1 ROUNDED = arithmetic-expression-1and so on for all the other statements (ADD, SUBTRACT, MULTIPLY). ## The REBOL equivalentREBOL has a separate function for rounding. It appears to be not present in earlier versions. identifier-2: round identifier-1The "round" function has refinements for rounding up or down, which way to go when the number is a half, and so on. Here is the "help" clipped out of the interpreter console (obtained with "help round"). >> help round USAGE: ROUND n /even /down /half-down /floor /ceiling /half-ceiling /to scale DESCRIPTION: Returns the nearest integer. Halves round up (away from zero) by default. ROUND is a function value. ARGUMENTS: n -- The value to round (Type: number money time) REFINEMENTS: /even -- Halves round toward even results /down -- Round toward zero, ignoring discarded digits. (truncate) /half-down -- Halves round toward zero /floor -- Round in negative direction /ceiling -- Round in positive direction /half-ceiling -- Halves round in positive direction /to -- Return the nearest multiple of the scale parameter scale -- Must be a non-zero value (Type: number money time) (SPECIAL ATTRIBUTES) catch |