Easytrieve Exponentiation Operator (**)

Double asterisk raises a numeric base to a numeric exponent—squaring a rate factor, cubing a unit conversion constant, or computing compound growth in analytical utilities. Exponentiation appears less often in classic nightly payroll than plus, minus, asterisk, and slash, but batch installations use ** in interest accrual prototypes, statistical sampling utilities, and engineering interface programs. ** binds tighter than multiplication and division—BASE * RATE ** 2 may square RATE before multiply depending on operand positions; parenthesize when business formula does not match default precedence. Results explode in magnitude—2 ** 20 exceeds million; packed field overflow abends or corrupts. This page teaches syntax, precedence, associativity footguns, sizing targets, contrast with multiply, and when repeated multiply replaces ** for clarity in maintenance-sensitive code.

Progress0 of 0 lessons

Basic Syntax

TARGET = base ** exponent. SQUARE = VALUE ** 2. CUBE = VALUE ** 3. Exponent may be field or literal—POWER = BASE ** EXP when exponent varies. Integer exponents most common in batch; fractional exponent semantics verify on installation if used.

text
1
2
3
SQUARE = RATE ** 2 VOLUME = SIDE ** 3 RESULT = BASE ** EXPONENT

Precedence

** relative to other operators
ExpressionEvaluation order
A * B ** 2B ** 2 first, then multiply by A
A + B ** 2B ** 2 first, then add A
(A + B) ** 2Add A + B first, then square
A ** B ** CAssociativity—parenthesize explicitly

Associativity Chains

2 ** 3 ** 2 may parse as (2 ** 3) ** 2 = 64 or 2 ** (3 ** 2) = 512 depending on product associativity rules—never leave ambiguous in financial code. Write explicit parens. Exponent towers grow fast—2 ** (2 ** 5) is astronomical for small fixed fields.

Overflow and Field Sizing

DEFINE RESULT W 15 P 4 for large intermediate when BASE and EXPONENT vary. Test MAX production values. Overflow invalidates packed sign—abend. For modest squares, W 11 P 4 may suffice when BASE known bounded.

** vs Repeated Multiply

SQUARE = X * X equivalent to X ** 2 for readability in some shops—no precedence surprise. CUBE = X * X * X versus X ** 3—choose style guide consistency. ** wins for exponent field variable when power not 2 or 3.

text
1
2
3
* Equivalent square: HOLD1 = RATE ** 2 HOLD2 = RATE * RATE

Use Cases in Batch

  • Compound interest prototype: AMOUNT * (1 + RATE) ** YEARS approximated with care.
  • Geometric scaling in rate tables.
  • Statistical variance utilities—square deviation from mean.
  • Engineering conversion when interface file requires power law.

Payroll tax percentage uses * not **—do not use ** for percent unless formula truly power law.

Exponentiation in IF

IF VALUE ** 2 GT THRESHOLD squares before compare—rare. Prefer HOLD = VALUE ** 2; IF HOLD GT THRESHOLD for debug DISPLAY of HOLD.

Common Exponentiation Mistakes

  • Confusing ** with single * multiply.
  • Unparenthesized exponent chain wrong magnitude.
  • Undersized target field overflow.
  • Using ** for simple percent—use * 0.10 instead.
  • Assuming Excel exponent rules without z/OS test.

Explain It Like I'm Five

Double star means multiply a number by itself several times. Two star three means two times two times two—eight. It goes faster than writing many times signs but makes big answers very quickly—pick a big enough box. Do the star group before regular times unless parentheses say otherwise.

Exercises

  1. Compute 3 ** 4 by hand; verify 81.
  2. Write (2 + 1) ** 3 versus 2 + 1 ** 3—different results.
  3. Replace RATE ** 2 with RATE * RATE.
  4. Size field for BASE ** 8 test with BASE 10.
  5. State precedence of ** vs * in one sentence.

Quiz

Test Your Knowledge

1. RESULT = BASE ** 2 computes:

  • BASE raised to power 2 (squared)
  • BASE times 2 only
  • BASE divided by 2
  • String repeat

2. ** binds compared to *:

  • Tighter—exponentiation before multiply
  • Looser than add only
  • Same as EQ
  • Last

3. 2 ** 10 yields:

  • 1024
  • 20
  • 12
  • 100

4. Exponentiation in payroll batch is:

  • Rare compared to + - * /
  • Required every line
  • JCL only
  • Invalid operator

5. Large exponent on fixed decimal field risks:

  • Overflow or abend
  • Always exact
  • Alphabetic conversion
  • File delete
Published
Read time14 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 exponentiation ** operator precedenceSources: Broadcom Easytrieve 11.6 Language Reference arithmetic operatorsApplies to: Easytrieve exponentiation operator