Arithmetic Operators

Arithmetic operators work on valid numeric constants or on variables that represent valid numeric constants.
Types of Numeric Constants
12
A whole number has no decimal point or commas. Results of arithmetic operations with whole numbers can contain a maximum of nine digits unless you override this default by using the NUMERIC DIGITS instruction. For information about the NUMERIC DIGITS instruction, see section section NUMERIC. Examples of whole numbers are:
123456789   0   91221  999
12.5
A decimal number includes a decimal point. Results of arithmetic operations with decimal numbers are limited to a total maximum of nine digits (NUMERIC DIGITS default) before and after the decimal. Examples of decimal numbers are:
123456.789  0.888888888
1.25E2
A floating point number in exponential notation, is said to be in scientific notation. The number after the "E" represents the number of places the decimal point moves. Thus 1.25E2 (also written as 1.25E+2) moves the decimal point to the right two places and results in 125. When an "E" is followed by a minus (-), the decimal point moves to the left. For example, 1.25E-2 is .0125.

You can use floating point numbers to represent very large or very small numbers. For more information about scientific notation (floating point numbers), see section Exponential Notation.

-12
A signed number with a minus (-) next to the number represents a negative value. A signed number with a plus (+) next to the number represents a positive value. When a number has no sign, it is processed as if it has a positive value.
The arithmetic operators you can use are:
Operator
Meaning
+
Add
-
Subtract
*
Multiply
/
Divide
%
Divide and return a whole number without a remainder
//
Divide and return the remainder only
**
Raise a number to a whole number power
-number
(Prefix -) Same as the subtraction 0 - number
+number
(Prefix +) Same as the addition 0 + number
Using numeric constants and arithmetic operators, you can write arithmetic expressions such as:
7 + 2                         /*  result is 9         */
7 - 2                         /*  result is 5         */
7 * 2                         /*  result is 14        */
7 ** 2                        /*  result is 49        */
7 ** 2.5                      /*  result is an error  */

Reference Reference

Feedback


Timestamp icon Last updated: Tuesday, 7 January 2014


http://pic.dhe.ibm.com/infocenter/cicsts/v5r1/topic/com.ibm.cics.rexx.doc//dfhrx/rvse015.html