REBOL for COBOL programmers

Go to table of contents Go to feedback page
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
Date revised:
Date reviewed:

This page explains some REBOL equivalents of ROUNDED.


COBOL ROUNDED

The 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-1
and so on for all the other statements (ADD, SUBTRACT, MULTIPLY).

The REBOL equivalent

REBOL has a separate function for rounding. It appears to be not present in earlier versions.

identifier-2: round identifier-1                 
The "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