The slash divides one numeric value by another, producing a quotient. Average pay is TOTAL divided by COUNT. Unit price is extended amount divided by quantity. Rate recovery divides tax by gross when rate field missing—guard divisor non-zero. Division shares precedence with multiplication and binds tighter than addition. Chained division evaluates left to right: 100 / 10 / 2 yields 5 then 2.5 depending on associativity—parenthesize when business formula demands explicit grouping. Division by zero is the primary runtime hazard—IF divisor GT 0 before every divide on variable count fields. Packed decimal quotients need target width and implied decimals for fractional averages—ROUNDED on assignment matches currency policy. This page teaches quotient patterns, zero guards, precision loss, divide in IF conditions, relation to MOD remainder, and contrast with multiply for inverse operations.
TARGET = dividend / divisor. AVG-GROSS = GRAND-TOTAL / REC-COUNT. UNIT-PRICE = EXT-AMT / QTY. Divisor must be non-zero at runtime. Literal divisor 100 converts percent display in some utility patterns—AMT / 100 when input stored as basis points—document convention.
12345IF REC-COUNT GT 0 AVG-GROSS = GRAND-TOTAL / REC-COUNT ROUNDED ELSE AVG-GROSS = 0 END-IF
Mandatory pattern for variable divisors: test before divide. COUNT from accumulation may be zero on empty file. QTY on order line may be zero on bad extract. IF COUNT GT 0 protects AVG assignment. ELSE branch sets default zero, skips record, or DISPLAY exception. Never divide by COUNT without guard in production—nightly empty file should not abend entire payroll step.
| Strategy | Pattern | When |
|---|---|---|
| IF GT 0 | IF COUNT GT 0 AVG = TOT / COUNT | Standard average |
| ELSE default | ELSE AVG = 0 | Empty set acceptable |
| Skip record | ELSE DISPLAY skip | Bad input row |
Financial average: sum divided by count with ROUNDED into P 2. GRAND-TOTAL accumulated in S field across records; REC-COUNT incremented each iteration; after loop or in trailer logic AVG = GRAND-TOTAL / REC-COUNT ROUNDED. Weighted average needs sum of products divided by sum of weights—multiply page for numerator accumulation.
Division expands fractional part—TOTAL 100 / COUNT 3 yields 33.333... ROUNDED into P 2 stores 33.33 per policy. TRUNCATED stores 33.33 without round up on third decimal—regulatory choice. Intermediate quotient in wider W field before final ROUNDED into report field prevents double-round errors.
A / B * C left to right: divide A by B, multiply result by C. A * B / C multiply first when * and / left associate. AMOUNT * RATE / 100 converts stored rate percent—parentheses if policy differs: (AMOUNT * RATE) / 100. Expression TOTAL / COUNT + ADJ adds ADJ after divide—divide before add unless parens.
Less common than assignment—IF TOTAL / COUNT GT LIMIT compares average to threshold when COUNT known non-zero from prior guard. Prefer assign AVG first then IF AVG GT LIMIT for clarity and single divide. IF QTY GT 0 AND EXT / QTY GT MAX-UNIT detects unit price exception—validate QTY before divide in same AND chain does not short-circuit—still test QTY GT 0 explicitly first line or use nested IF.
If TAX = GROSS * RATE then GROSS = TAX / RATE when RATE non-zero recovers gross from tax line—algebraic check in audit scripts. RATE = TAX / GROSS when GROSS GT 0 derives effective rate for exception report.
Slash yields quotient whole and fractional part in one number. MOD yields remainder—use for even-odd, batch slot, cycle detection. 10 / 3 quotient 3.333; 10 MOD 3 remainder 1 per MOD semantics on your release.
Divisor COUNT with corrupt packed sign causes abend like dividend issues—validate NUMERIC on both operands for FILE-sourced fields. FLDCHK during test.
Divide shares marbles into equal groups. Ten marbles divided by two groups gives five each. You cannot divide by zero groups—the computer gets upset. Averages are total marbles divided by how many friends shared. Sometimes you round the answer to two decimal places for pennies.
1. AVG = TOTAL / COUNT divides:
2. Division by zero in Easytrieve:
3. AVG = TOTAL / COUNT ROUNDED:
4. / and * at same precedence evaluate:
5. Integer versus fractional quotient on P fields: