Easytrieve DECIMALS

The DECIMALS topic in field definitions is the decimal-positions parameter—the optional integer you code after the type letter on DEFINE and FILE lines. It does not add bytes to the field. It tells Easytrieve how many digit positions lie to the right of an implied decimal point inside the storage already described by length and type. GROSS 94 4 P 2 is four packed bytes where the last two digit positions represent cents. SERVICE 15 2 N 0 is whole years without fractional part—but still quantitative because zero is explicitly coded. Omit decimals entirely and the same bytes may be treated as unsigned non-quantitative with different sign handling and no automatic SUM. This page is the field-definition focused companion to the data types decimal page: how to code decimals on DEFINE, valid ranges per type, interaction with MASK and assignment options, and mapping COBOL V clauses.

Progress0 of 0 lessons

Syntax on DEFINE and FILE

Pattern: field-name, location, length, type-letter, decimal-positions. The decimal count is not written with a period—it is a separate integer token. P 5 2 is valid. P 5.2 is wrong syntax. EVEN for packed may follow decimals on P fields only.

text
1
2
3
4
5
PAY-GROSS 94 4 P 2 TAX-RATE W 3 P 4 HOURS 18 3 P 1 SERVICE W 2 N 0 DEPT 98 3 N

PAY-GROSS uses two decimals for currency. TAX-RATE four decimals for fractional rate 0.0825. HOURS one decimal for half-hour units. SERVICE uses explicit zero decimals for whole years. DEPT omits decimals—non-quantitative zoned if used as unsigned counter.

Valid Ranges by Type

Decimal-positions limits
TypeDecimal rangeExample
N0–18AMT 10 9 N 2
P0–18GROSS 94 4 P 2
B0–10RATE 40 4 B 4
U0–18QTY 50 3 U 0
I0 onlyCOUNT W 4 I
ANot valid

Quantitative vs Omitting DECIMALS

Broadcom application guide states specifying decimal positions designates the field as signed quantitative—required for signed arithmetic and automatic totaling on control reports. Fields without decimal positions on numeric types are non-quantitative unsigned—leading zeros on print, positive sign assumptions on assignment left side. Currency almost always needs explicit decimals. Counters and codes sometimes omit decimals intentionally.

  • Quantitative P 4 2: signed salary, SUM on reports, negative amounts allowed.
  • Non-quantitative P 4: four packed bytes as unsigned magnitude—rare for money.
  • Quantitative N 3 0: signed whole zoned integer—explicit zero decimals.
  • Non-quantitative N 3: three zoned bytes without signed decimal semantics.

COBOL V Clause Mapping

PIC S9(5)V99 COMP-3: five digits plus two fractional digits in five packed bytes—P 5 2. PIC 9(7)V99 display: eleven digit positions if V included in digit count—often N 11 2 for zoned. PIC S9(4)V9 COMP binary: verify COMP size—may be B 2 4 for four decimal places in two-byte binary quantitative field. V in COBOL counts decimal places; map to decimal-positions integer, not to extra length bytes.

DECIMALS and Arithmetic Assignment

Receive field decimal count influences stored scale after assignment. ROUNDED adjusts to receive decimals. TRUNCATED drops excess fractional digits. INTEGER truncates toward zero. Dividing two P 2 fields and storing in P 2 without rounding may lose fractional cents—test with known amounts. Literal 1234.56 assigns into P 5 2 with conversion per assignment rules.

text
1
2
3
WS-TAX = GROSS * 0.15 WS-NET = GROSS - WS-TAX ROUNDED WS-PCT = (PART / TOTAL) * 100 TRUNCATED

DECIMALS and Default Masks

Quantitative fields receive system default edit masks accounting for decimal count—commas and decimal point on LINE output. Override with MASK on same DEFINE. MASK nine count must align with field digits including decimal places. BWZ blank-when-zero works on quantitative fields with all zero amount.

DECIMALS and SUM on Reports

REPORT SUM statement accumulates quantitative numeric fields. Fields with decimal positions specified participate when named in SUM. SUM on wrong scale field—missing decimals on amount—totals look like dollars but are stored as cents magnitude or vice versa. Reconcile SUM output against manual spreadsheet before production promotion.

Zero vs Omitted Decimals

N 2 0 explicitly quantitative with zero fractional digits. N 2 without third numeric parameter is non-quantitative—different rules. When copybook says whole number signed, prefer explicit 0 decimals for clarity in maintenance reviews.

Common DECIMALS Mistakes

  1. Missing V99 on salary P field—100x report errors.
  2. Decimals on type A date string fields—invalid.
  3. More decimal positions than field digit capacity allows.
  4. Confusing literal decimal point with decimal-positions parameter.
  5. Expecting I fields to hold cents—use P or N instead.

Explain It Like I'm Five

DECIMALS tells the program where the cents part starts without drawing a dot on the number. Two decimals mean the last two digits are pennies. Zero decimals mean whole numbers only. If you forget to say how many cents digits exist, the program treats the box differently— like a whole piggy bank instead of dollars and cents.

Exercises

  1. Code GROSS as 4 P 2 at byte 94.
  2. Map PIC S9(5)V99 COMP-3 to length type decimals.
  3. Explain quantitative P 5 vs P 5 2.
  4. Write assignment with ROUNDED into P 5 2 receive field.
  5. List max decimals for B and P types.

Quiz

Test Your Knowledge

1. Decimal-positions on DEFINE must be:

  • Unsigned integer 0-18 on numeric types
  • Alphabetic literal
  • Required on all types
  • Always 2

2. Specifying decimal positions—even zero—makes a field:

  • Quantitative signed
  • Alphabetic
  • Read-only
  • Varying length

3. Type A fields can have decimal positions:

  • No—not valid
  • Yes 0-18
  • Yes always 2
  • Only on FILE

4. P 5 2 means:

  • Five packed bytes with two implied decimal places
  • Five point two literal
  • Five digits no decimals
  • Two bytes packed

5. Omitting decimals on numeric FILE amount often causes:

  • Non-quantitative unsigned treatment and missing SUM
  • Compile failure always
  • Automatic two decimals
  • Type change to A
Published
Read time13 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 decimal-positions quantitative fieldsSources: Broadcom Easytrieve 11.6 DEFINE Statement, Describe Files and Fields, Application GuideApplies to: Easytrieve DECIMALS parameter on field definitions