The minus sign subtracts one numeric value from another—gross minus tax, balance minus payment, count minus one—or negates a single value when used as unary minus. Net pay is the archetypal subtraction chain: start with gross, subtract federal tax, state tax, FICA, other deductions until net remains. Easytrieve evaluates chained subtraction left to right at the same precedence level as addition unless parentheses group terms. Negative results require field definitions that support signed packed or zoned storage; unsigned fields may produce invalid sign nibbles when subtraction would go below zero. Beginners use subtraction inside IF to detect negative net before PUT—IF (GROSS - DEDUCT) LT 0— without assigning NET first. This page covers binary minus syntax, chained deductions, unary negation, signed versus unsigned targets, interaction with multiply precedence, and validation patterns for payroll exception reporting.
TARGET = left - right subtracts right from left. NET = GROSS - DEDUCT stores difference. Operands follow same numeric type rules as addition—packed P, zoned N, binary B, literals. Implied decimals align on P fields—subtracting P 2 from P 2 preserves scale in result when target sized correctly.
123NET-PAY = GROSS - FED-TAX - STATE-TAX - FICA VARIANCE = BUDGET - ACTUAL REMAIN = LIMIT - COUNT
NET = GROSS - A - B - C parses as ((GROSS - A) - B) - C with left-to-right associativity at same precedence as addition. Equivalent to subtracting sum when deductions grouped: TOTAL-DED = A + B + C; NET = GROSS - TOTAL-DED. Grouping deductions into TOTAL-DED clarifies audit trail and allows DISPLAY of total deductions before net. Parentheses override: NET = GROSS - (A + B + C) subtracts combined deductions in one step after add inside parens.
| Form | Evaluation | When to use |
|---|---|---|
| GROSS - A - B - C | Left-to-right subtract | Simple legacy style |
| GROSS - (A + B + C) | Sum deductions then subtract | Clear single deduction total |
| TOTAL-DED = A+B+C; NET = GROSS - TOTAL-DED | Two statements | Audit DISPLAY of TOTAL-DED |
Unary minus negates one operand: ADJ = -CORRECTION stores negative correction amount. BALANCE = -OLD-BAL when reversing entry sign. Unary minus binds tightly—evaluate before add subtract at same expression level per precedence rules. Invalid packed on negated field still abends—validate source.
12ADJ-AMT = -CORRECTION NET = GROSS + ADJ-AMT
Quantitative packed fields with decimal positions support signed arithmetic in standard payroll definitions. Subtracting deductions from gross into NET P 2 allows negative net if deductions exceed gross—business may flag as error. Unsigned N fields without sign representation may corrupt on negative mathematical result. Define NET with sign capacity when over-deduction is possible during test. IF (GROSS - DEDUCT) LT 0 branches to exception without storing invalid NET.
Plus and minus share precedence level—evaluate left to right among them. RESULT = 100 - 50 + 25 yields 75: subtract 50 from 100, add 25. RESULT = 100 - (50 + 25) yields 25 when parens group add first. Multiply and divide bind tighter: NET = GROSS - DEDUCT * RATE may multiply DEDUCT * RATE before subtract from GROSS—likely wrong for tax; use NET = GROSS - (DEDUCT * RATE) or separate assignments.
IF GROSS - TOTAL-DEDUCT LT 0 detects negative net in one condition—subtraction before relational LT. IF (BUDGET - ACTUAL) GT TOLERANCE finds variance over threshold. Parentheses recommended for readability even when precedence suffices. Combine with NUMERIC guards on FILE operands before subtraction in condition.
123IF (GROSS - TOTAL-DEDUCT) LT 0 DISPLAY 'NEGATIVE NET' EMPL-NUM GROSS TOTAL-DEDUCT END-IF
Budget minus actual yields variance for management reports. Limit minus count shows remaining capacity. Date arithmetic may use specialized routines—display date subtraction as raw minus on alphabetic date fields is unreliable; use DATECALC or internal date representation pages for calendar math. Subtraction on day-offset internal dates is numeric subtract on P fields after conversion.
When subtracting rounded product from gross, round product first: TAX = GROSS * RATE ROUNDED; NET = GROSS - TAX. TRUNCATED on final NET assignment drops excess precision when regulations require truncation not round on net pay line.
Minus takes marbles away. Ten marbles minus three leaves seven. Chained minus goes left to right: ten minus three minus two means seven then five. Parentheses say add what you subtract first—ten minus (three plus two) leaves five. A minus sign in front of one number flips it to opposite direction—like owing marbles instead of having them.
1. NET = GROSS - DEDUCT uses - to:
2. NET = GROSS - TAX - FICA evaluates:
3. IF (GROSS - DEDUCT) LT 0 detects:
4. Unary minus on numeric field:
5. Subtracting larger from smaller on unsigned field may: