< Rexx Programming < How to Rexx
The rexx scripting language provides a set of arithmetic operators 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 operators, 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 operators should only be used on strings containing numeric values, otherwise an error may occur.
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.