all bits have now been inspected, the initial calculation is complete; otherwise the accumulator is squared
and the next bit is inspected for multiplication. When the initial calculation is complete, the temporary result
is divided into 1 if the power was negative.
The multiplications and division are done under the arithmetic operation rules, using a precision of DIGITS
+ L + 1 digits. L is the length in digits of the integer part of the whole number
n
(that is, excluding any
decimal part, as though the built-in function
TRUNC(
n
)
had been used). Finally, the result is rounded to
NUMERIC DIGITS digits, if necessary, and insignificant trailing zeros are removed.
Integer Division
The
% (integer divide) operator
divides two numbers and returns the integer part of the result. The result
returned is defined to be that which would result from repeatedly subtracting the divisor from the dividend
while the dividend is larger than the divisor. During this subtraction, the absolute values of both the
dividend and the divisor are used: the sign of the final result is the same as that which would result from
regular division.
The result returned has no fractional part (that is, no decimal point or zeros following it). If the result
cannot be expressed as a whole number, the operation is in error and will fail—that is, the result must not
have more digits than the current setting of NUMERIC DIGITS. For example,
10000000000%3
requires 10
digits for the result (3333333333) and would, therefore, fail if
NUMERIC DIGITS 9
were in effect. Note that
this operator may not give the same result as truncating regular division (which could be affected by
rounding).
Remainder
The
// (remainder) operator
returns the remainder from integer division and is defined as being the
residue of the dividend after the operation of calculating integer division as previously described. The sign
of the remainder, if nonzero, is the same as that of the original dividend.
This operation fails under the same conditions as integer division (that is, if integer division on the same
two terms would fail, the remainder cannot be calculated).
Additional Operator Examples
Following are some examples using the power, integer divide, and remainder operators:
/* Again with:
Numeric digits 5 */
2**3
->
8
2**-3
->
0.125
1.7**8
->
69.758
2%3
->
0
2.1//3
->
2.1
10%3
->
3
10//3
->
1
-10//3
->
-1
10.2//1
->
0.2
10//0.3
->
0.1
3.6//1.3
->
1.0
Notes:
1. A particular algorithm for calculating powers is used, because it is efficient (though not optimal) and
considerably reduces the number of actual multiplications performed. It, therefore, gives better
performance than the simpler definition of repeated multiplication. Because results may differ from
those of repeated multiplication, the algorithm is defined here.
2. The integer divide and remainder operators are defined so that they can be calculated as a by-product
of the standard division operation. The division process is ended as soon as the integer result is
available; the residue of the dividend is the remainder.
Numbers and Arithmetic
Chapter 16. Numbers and Arithmetic
221
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...