![]() |
REBOL for COBOL programmers |
Table of contents Generalities Introduction Reserved words What you may/must say Right-to-left evaluation Programming by side effects Code is data The Global Context Coding REBOL like COBOL IDENTIFICATION DIVISION ENVIRONMENT DIVISION FILE SECTION WORKING-STORAGE SECTION SCREEN SECTION PROCEDURE DIVISION COPY statement Printing Your own mezzanine Module testers Module documentation idea Program structure suggestion List of all code samples Some useful equivalencies ACCEPT ADD COMPUTE DISPLAY DIVIDE EXIT INSPECT MOVE MULTIPLY IF OCCURS PERFORM READ REMAINDER ROUNDED SEARCH SET TODAYS-DATE TIME VALUE What's in your head, Boy? Introduction Similar but not the same Colon is not assignment Be careful defining A shorter letter On punctuation Why so dense? Doing COBOLish things Fixed-format file Sample applications Introduction Source code as corporate asset NACHA list Introduction Global services modules Start writing |
ROUNDED
Date written: March 25, 2013 This page explains some REBOL equivalents of 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 |