Definition
A precise definition of the arithmetic facilities of the REXX language is given here.
Numbers
A
number
in REXX is a character string that includes one or more decimal digits, with an optional decimal
point. (See section “Exponential Notation” on page 222 for an extension of this definition.) The decimal
point may be embedded in the number, or may be a prefix or suffix. The group of digits (and optional
decimal point) constructed this way can have leading or trailing blanks and an optional sign (
+
or
-
) that
must come before any digits or decimal point. The sign can also have leading or trailing blanks.
Therefore,
number
is defined as:
blanks
sign
blanks
digits
digits
.
digits
.
digits
digits
.
blanks
blanks
are one or more spaces
sign
is either
+
or
−
digits
are one or more of the decimal digits
0
–
9
.
Note that a single period alone is not a valid number.
Precision
Precision is the maximum number of significant digits that can result from an operation. This is controlled
by the instruction:
NUMERIC DIGITS
expression
;
The
expression
is evaluated and must result in a positive whole number. This defines the precision
(number of significant digits) to which calculations are carried out. Results are rounded to that precision, if
necessary.
If you do not specify
expression
in this instruction, or if no NUMERIC DIGITS instruction has been
processed since the start of a program, the default precision is used. The REXX standard for the default
precision is
9
.
Note that NUMERIC DIGITS can set values below the default of nine. However, use small values with
care—the loss of precision and rounding thus requested affects all REXX computations, including, for
example, the computation of new values for the control variable in DO loops.
Arithmetic Operators
REXX arithmetic is performed by the operators
+
,
-
,
*
,
/
,
%
,
//
, and
**
(add, subtract, multiply, divide,
integer divide, remainder, and power), which all act on two terms, and the prefix plus and minus operators,
which both act on a single term. This section describes the way in which these operations are carried out.
Before every arithmetic operation, the term or terms being operated upon have leading zeros removed
(noting the position of any decimal point, and leaving only one zero if all the digits in the number are
zeros). They are then truncated (if necessary) to 1 significant digits before being used in the
computation. (The extra digit is a “guard” digit. It improves accuracy because it is inspected at the end of
Numbers and Arithmetic
218
CICS TS for VSE/ESA: REXX Guide
Summary of Contents for SC34-5764-01
Page 1: ...CICS Transaction Server for VSE ESA REXX Guide SC34 5764 01...
Page 2: ......
Page 3: ...CICS Transaction Server for VSE ESA REXX Guide SC34 5764 01...
Page 22: ...xx CICS TS for VSE ESA REXX Guide...
Page 23: ...Part 1 User s Guide Copyright IBM Corp 1992 2009 1...
Page 24: ...2 CICS TS for VSE ESA REXX Guide...
Page 40: ...18 CICS TS for VSE ESA REXX Guide...
Page 54: ...Using Variables and Expressions 32 CICS TS for VSE ESA REXX Guide...
Page 106: ...84 CICS TS for VSE ESA REXX Guide...
Page 110: ...88 CICS TS for VSE ESA REXX Guide...
Page 122: ...100 CICS TS for VSE ESA REXX Guide...
Page 123: ...Part 2 Reference Copyright IBM Corp 1992 2009 101...
Page 124: ...102 CICS TS for VSE ESA REXX Guide...
Page 130: ...Introduction 108 CICS TS for VSE ESA REXX Guide...
Page 152: ...REXX General Concepts 130 CICS TS for VSE ESA REXX Guide...
Page 224: ...Functions 202 CICS TS for VSE ESA REXX Guide...
Page 252: ...230 CICS TS for VSE ESA REXX Guide...
Page 278: ...256 CICS TS for VSE ESA REXX Guide...
Page 312: ...DB2 Interface 290 CICS TS for VSE ESA REXX Guide...
Page 316: ...High level Client Server Support 294 CICS TS for VSE ESA REXX Guide...
Page 340: ...318 CICS TS for VSE ESA REXX Guide...
Page 344: ...for execs Commands 322 CICS TS for VSE ESA REXX Guide...
Page 399: ...Part 3 Appendixes Copyright IBM Corp 1992 2009 377...
Page 400: ...378 CICS TS for VSE ESA REXX Guide...
Page 438: ...416 CICS TS for VSE ESA REXX Guide...
Page 442: ...System Definition Customization Administration 420 CICS TS for VSE ESA REXX Guide...
Page 446: ...Security 424 CICS TS for VSE ESA REXX Guide...
Page 448: ...426 CICS TS for VSE ESA REXX Guide...
Page 464: ...442 CICS TS for VSE ESA REXX Guide...
Page 466: ...444 CICS TS for VSE ESA REXX Guide...
Page 468: ...446 CICS TS for VSE ESA REXX Guide...
Page 476: ...454 CICS TS for VSE ESA REXX Guide...
Page 478: ...456 CICS TS for VSE ESA REXX Guide...
Page 479: ......
Page 480: ...SC34 5764 01...
Page 481: ...Spine information CICS TS for VSE ESA REXX Guide...