Math functions and operators extend beyond everyday ABS and rounding into powers, roots, and transcendental calculations used in statistical, scientific, and engineering batch jobs on mainframe data. Exponentiation operator ** raises values to powers in arithmetic expressions—COMPOUND = PRINCIPAL * RATE ** YEARS in simplified illustrative formulas. SQRT and logarithm builtins appear in Easytrieve Plus Application Reference where licensed. Operator precedence determines evaluation order: ** before * and / before + and -. Parentheses override for clarity. Math category complements numeric category—route variance checks to numeric ABS; route distance or standard deviation components to math. Division by zero and negative SQRT input cause runtime failures—guard with IF. This index catalogs math capabilities, contrasts operators with function calls, explains precedence with examples, and notes Report Generator limitations versus Plus catalogs for advanced names.
Math happens inside arithmetic-expression on assignment and conditional lines. Operators + - * / ** combine numeric fields and literals. Function calls like SQRT(x) nest inside expressions when documented. Result type follows operand promotion rules—fractional results into integer-defined fields need ROUNDED TRUNCATED or INTEGER modifier on assignment.
| Operation | Mechanism | Notes |
|---|---|---|
| Addition | + operator | See addition operator tutorial |
| Subtraction | - operator | Unary minus in expressions |
| Multiplication | * operator | Scale propagation on P fields |
| Division | / operator | Guard zero divisor |
| Exponentiation | ** operator | Power precedence high |
| Square root | SQRT(expr) | Plus—verify availability |
| Logarithm | LOG(expr) per manual | Domain positive only |
| Nested formulas | Parentheses | Clarity and override precedence |
SIDE ** 2 squares a value for area calculations. BASE ** EXPONENT raises to arbitrary integer power—watch overflow when exponent large and base big. Non-integer exponents may require function form if documented. ** binds tighter than * so A * B ** 2 multiplies A by B squared not (A*B) squared unless parenthesized.
123AREA = LENGTH ** 2 VOLUME = LENGTH ** 3 COMPOUND-FACTOR = (1 + RATE) ** PERIODS
| Rank | Operators | Example |
|---|---|---|
| 1 (tightest) | ** | 2 + 3 ** 2 → 11 |
| 2 | * / | 10 - 8 / 2 → 6 |
| 3 (loosest) | + - | Left to right at same rank |
| Override | ( ) | (10 - 8) / 2 → 1 |
SQRT returns square root for non-negative operand in documented implementations. Negative input causes runtime error—IF X GE 0 before assign. Result may be fractional—assign into P field with adequate decimal count. Integer-only contexts use INTEGER or ROUNDED after SQRT. Higher roots may use ** (1.0/n) pattern if fractional exponent supported—verify compiler behavior on your release before relying on non-integer **.
LOG functions support growth rate and entropy-style calculations rare in classic payroll but present in forecast batch jobs. Domain errors on non-positive arguments—validate input range in IF. Combine with ABS from numeric category when log of magnitude needed without sign. Profile runtime on large files—transcendental functions cost more than add.
MOD remainder operator documented under operators section complements math for cyclic keys—IF MOD(SEQ, 10) EQ 0 for every tenth record sampling. See MOD operator tutorial for divide-by-zero guard on modulus.
Numeric: ABS MIN MAX rounding modifiers for business rules. Math: ** SQRT LOG advanced expression forms. Payroll tip: gross minus tax lives in numeric; engineering unit conversion with powers lives in math. Cross-link both indexes when job mixes variance ABS with statistical root mean square.
Long fractional intermediate results assign into short P fields—explicit ROUNDED on assignment documents penny policy. Chain: WS-FULL = SQRT(VARIANCE) then DISPLAY-FLD = WS-FULL ROUNDED into P 2. Skipping intermediate W field loses precision in multi-step actuarial formulas.
Math tools are fancy calculators inside your recipe. Plus and minus mix ingredients. Times and divide share or split piles. ** means multiply a number by itself a counted number of times—two star two is four. SQRT asks what number times itself gives this square—reverse of **. Parentheses tell the calculator which part to do first so the recipe does not come out wrong.
1. BASE ** 2 in Easytrieve means:
2. SQRT function availability:
3. Math category differs from numeric because:
4. Expression 2 + 3 ** 2 evaluates ** first giving:
5. Divide by zero in math expression: