411 REFERENCE · Wikibooks
Rexx Programming/How to Rexx/arithmetic
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
The rexx scripting language provides a set of arithmetic /operator/s for manipulating /integer/ and /floating point/ numbers.
Operator Description
+ addition
- subtraction
* multiplication
/ division
% integerdivision
// modulus
** exponent
say 6 + 3 /* addition */
say 8 - 3 /* subtraction */
say 6 * 3 /* multiplication */
say 11 / 4 /* division */
say 11 % 4 /* integer division */
say 11 // 4 /* modulus */
say 5 ** 3 /* exponent */
Arithmetic operators may behave differently than they do in other programming languages
Note that rexx uses unconventional arithmetic /operator/s, which may have a different meaning to conventional operators used in other programming languages. For example the percent sign is used for integer division in rexx, whereas it is used as a modulus operator in perl.
Arithmetic operations should only be applied to valid numeric values
The rexx scripting language uses typeless variables that are treated as strings. Arithmetic /operator/s should only be used on strings containing numeric values, otherwise an error may occur.