1.2.2 Using Arithmetic Operators and Functions

Six standard arithmetic operators are available for use in $repeat and $macro commands. The following table lists these operators and their order of precedence, from highest to lowest.

Table 1-3. Arithmetic Operators
OperatorExamplesDescriptionPrecedence
**2**3Exponentiation1
*2*IMultiplication2
/4/2Division2
%9%8Modulus2
+2+4Addition3
-4-ISubtraction3

One arithmetic function is available for use in arithmetic expressions used in $repeat and $macro commands. The following table shows the arithmetic function and its bases.

Table 1-4. Arithmetic Function and Bases
FunctionBase
LOG2Binary
LOG8Octal
LOG16Hexadecimal
LOGDecimal
The LOG function returns an integer value. For example:
LOG2(32)= 5 <==> 2**5 = 32

LOG2(33)= ceil(5.0444) = 6 <==> 2**6 = 64

Ceil(x) returns the smallest integer that is not less than x.