In Easytrieve, decimal is not a separate data type like character or packed decimal. Instead, decimal precision is controlled by the decimal-positions parameter you code after the type letter on DEFINE and FILE lines. A salary stored as P 5 2 holds five bytes of packed data where the last two digit positions represent cents—12345 in storage might mean 123.45 dollars depending on editing and assignment rules. Getting decimal positions wrong is one of the most expensive beginner mistakes: amounts look plausible on reports but SUM totals are off by a factor of one hundred, or every field after a misaligned packed definition reads garbage. This page explains implied decimals, quantitative fields, valid ranges per type, assignment rounding, and how decimal positions connect to COBOL copybooks and report SUM behavior.
Easytrieve numeric storage uses type letters N, P, B, U, and I. Decimal precision attaches to the first four of those—not to I, which must have zero or blank decimal positions. When documentation refers to a quantitative field, it means you specified decimal positions after the type code. Quantitative fields participate in signed arithmetic and automatic totaling on reports when referenced in SUM statements. Omitting decimal positions on a P field that holds currency tells the compiler to treat the value as unsigned non-quantitative, which changes sign handling and default editing.
| Type | Name | Max decimal positions | Example declaration |
|---|---|---|---|
| N | Zoned decimal | 0–18 | AMT 10 9 N 2 |
| P | Packed decimal | 0–18 | GROSS 27 5 P 2 |
| B | Binary | 0–10 | RATE 40 4 B 4 |
| U | Unsigned packed | 0–18 | QTY 50 3 U 0 |
| I | Integer | 0 only | COUNT W 4 I |
| A | Alphabetic | Not valid | NAME 1 16 A |
Pattern: field-name, location, length, type letter, optional decimal positions. The decimal count is an unsigned integer—it is not written with a decimal point in source. P 5 2 means five-byte packed with two places after the implied decimal point, not five point two as a literal. FILE and DEFINE share the same attribute pattern. Overlay fields inherit parent location; decimal positions on overlays must align with how you interpret the underlying bytes.
12345678FILE PAYROLL FB(200 2000) EMPNO 1 6 N 0 GROSS 10 5 P 2 TAX-PCT 15 3 P 4 HOURS 18 3 P 1 DEFINE WS-NET W 5 P 2 DEFINE WS-FLAG W 2 B
GROSS uses two decimal places typical for dollars and cents. TAX-PCT with P 4 stores 0.0825 as a fractional rate—four decimal positions preserve precision for percentage calculations. HOURS with one decimal supports half-hour increments. WS-FLAG omits decimal positions entirely, making B non-quantitative for bit-style data rather than signed fractional binary.
Internal arithmetic respects implied decimal alignment. Adding GROSS and BONUS both P 2 produces a P result scaled consistently. Multiplying GROSS P 2 by a literal 0.15 applies decimal rules from assignment documentation—intermediate precision may exceed storage width before ROUNDED or TRUNCATED trims the receive field. Division especially exposes scale issues: dividing two P 2 fields and storing into P 2 without rounding may truncate fractional cents.
123WS-TAX = GROSS * 0.15 WS-NET = GROSS - WS-TAX ROUNDED WS-RATE = (PART / TOTAL) * 100 TRUNCATED
ROUNDED adjusts the stored value to the receive field decimal count using product rounding rules. TRUNCATED discards excess fractional digits. INTEGER truncates toward zero for integer-style receive fields. These options apply only when the receive field is numeric—never on type A assignments.
Broadcom text conventions distinguish signed quantitative fields—those with decimal positions specified—from unsigned non-quantitative fields where decimal positions are omitted. Quantitative zoned and packed fields use sign nybbles or zone digits for negative values during assignment. Non-quantitative numeric fields treat storage as unsigned; assignment to the left side of an equation may force a positive sign. For currency you almost always want quantitative definitions with appropriate decimal count.
Mapping COBOL to Easytrieve decimal positions requires reading PIC clauses, not guessing from display width. PIC S9(5)V99 COMP-3 is five digits plus two fractional digits in packed form—five bytes P 2. PIC 9(7)V9(2) display is nine digits total with two after the implied decimal—often N 9 2 if stored zoned. COMP binary counts differ: PIC S9(9) COMP may be four-byte B 0 quantitative. Mis-counting V99 decimals shifts every subsequent FILE position when you transcribe copybooks manually.
| COBOL | Easytrieve | Notes |
|---|---|---|
| PIC S9(5)V99 COMP-3 | 5 P 2 | Five packed bytes, two implied decimals |
| PIC 9(9)V99 | 11 N 2 | Eleven zoned digits if display storage |
| PIC S9(4)V9999 COMP | 2 B 4 | Binary rate field—verify COMP size |
| PIC 9(5) | 5 N 0 | Whole number—zero decimal positions |
Quantitative fields receive default system edit masks that insert commas and decimal points on LINE and TITLE output. A P 7 2 field with value representing 1000.00 may print with comma grouping per default mask tables. Override with MASK on DEFINE when you need credit indicators, floating dollar signs, or blank-when-zero BWZ. MASK affects display only—the stored packed value unchanged. Decimal count on the field drives how many nines appear in the mask literal relative to field width.
Numeric literals accept up to eighteen digits with optional sign and one decimal point in the literal itself—distinct from field decimal positions. Literal 1234.56 assigns into P 5 2 with conversion. Assigning a literal with more fractional digits than the target field supports triggers rounding or truncation per assignment options. Match literal scale to field scale when testing IF thresholds—IF AMT GT 999.99 on a P 5 2 field compares against the implied two-decimal amount.
Imagine counting coins in a jar labeled dollars and cents. Decimal positions tell Easytrieve where the cents part starts without drawing a dot on every coin. If you say this jar holds numbers with two secret cents digits at the end, 12345 means 123 dollars and 45 cents. If you forget to say there are cents digits, the computer thinks you have twelve thousand three hundred forty-five dollars instead—and that is a very different allowance.
1. Decimal positions on a DEFINE line apply to which field types?
2. A field defined as P 5 2 is quantitative because:
3. Maximum decimal positions on a packed P field is:
4. ROUNDED on assignment affects:
5. COBOL PIC S9(5)V99 COMP-3 maps to Easytrieve as approximately: