Easytrieve and Floating Point

Beginners arriving from Java, Python, or C often search Easytrieve documentation for float or double types and find none. Broadcom Easytrieve Report Generator defines fields with type codes A, M, K, N, P, B, U, and I—fixed-length character and decimal-family numerics—not IEEE 754 floating point. That design aligns with decades of mainframe practice where payroll, billing, and general ledger amounts travel as packed decimal COMP-3 or zoned PIC 9 fields with implied decimal places. This page explains why floating point is absent, what to use instead, how scaling and decimal positions substitute for exponent-based storage, and how to handle COBOL COMP-1 and COMP-2 interfaces when they appear at the edge of your Easytrieve programs.

Progress0 of 0 lessons

No Native Float Type Code

The DEFINE statement field-length table lists A, K, M, N, P, B, U, and I. There is no F for float, no D for double, and no explicit IEEE binary16/binary32/binary64 letter. Arithmetic expressions operate on numeric fields and literals converted to internal decimal-friendly forms—not on hardware floating-point registers as a primary model. For report generation this is a feature: SUM on thousands of P 2 salary lines matches auditor expectations; float accumulation can drift by cents across large extracts.

Fixed Decimal as the Standard Substitute

Implied decimal positions on P, N, B, and U encode fractional values without a separate exponent byte. Rate 8.25 percent might store as P 3 4 where digits represent 0.0825. Currency $1234.56 uses P 5 2. Comparison and IF logic use the same scaled values. ROUNDED and TRUNCATED assignment options control how excess precision drops when storing results.

text
1
2
3
4
5
DEFINE TAX-RATE W 3 P 4 VALUE 0.0825 DEFINE GROSS W 5 P 2 DEFINE WS-TAX W 5 P 2 WS-TAX = GROSS * TAX-RATE ROUNDED
Floating-point concept to Easytrieve fixed decimal mapping
ConceptEasytrieve approachNotes
Fractional rateP or N with high decimal countP 3 4 for four decimal places
CurrencyP 5 2 typicalMatches COMP-3 V99
Large integer countI 4 or I 8Whole numbers only
Very small epsilonScale up (micro-units as int)Store millionths as integer I

Scaling Workaround for Wide Dynamic Range

When values span huge magnitude—scientific notation territory—float would use exponent. Easytrieve batch reports rarely need that. When they do, shops store micro-dollars as integer I 8 (cents times one million) or keep two fields: mantissa P and scale N. Document the scale in comments and conversion macros. Dividing before multiply loses precision; multiply first then divide with ROUNDED where manuals allow.

Literals With Decimal Points

Numeric literals accept optional sign, up to eighteen digits, and one decimal point in the literal text—1234.5678 assigns into fields with matching or smaller decimal capacity. Literal decimals differ from field decimal positions: the literal carries its own visible point while P 5 2 stores implied decimals without a physical dot in the packed nybbles.

COBOL COMP-1 and COMP-2 Interfaces

COBOL short and long floating-point items are not mapped one-to-one in DEFINE type tables. Files containing COMP-1 require knowing byte length—four bytes short float, eight bytes long float on IBM mainframe hex float format historically. Practical approaches: preprocess files to packed decimal in a COBOL or sort step before Easytrieve; define a four-byte or eight-byte B overlay and call an external routine to convert; or restrict Easytrieve to downstream reports after conversion jobs. Do not declare COMP-1 as P hoping digits align—they will not.

Binary Type B With Decimals

Quantitative B with decimal positions 0–10 supports fixed-point binary fractions in rare layouts. High-order bit becomes sign. This is still fixed-point binary integer scaled by implied decimals—not IEEE float. Capacity tables in DEFINE documentation list max binary values by length. Use only when copybook explicitly defines binary fixed-point, not as a general float replacement.

Why Mainframe Batch Prefers Fixed Decimal

  • Auditors reconcile SUM totals to the penny against ledger systems.
  • COBOL upstream systems already emit COMP-3 packed amounts.
  • Report masks expect comma and decimal editing on quantitative P and N.
  • Float rounding errors accumulate inadvisably across millions of detail lines.
  • Regulatory extracts require reproducible exact digit results.

Display and Debugging

DISPLAY on P fields shows edited decimal digits readable in SYSPRINT. There is no %G format style float print. For suspected conversion issues, DISPLAY HEX on binary overlays shows raw bytes before external float conversion. FLDCHK debug option catches some invalid numeric data during test runs.

Integration With External Float Systems

PC analytics and JSON APIs often use double. ETL at the boundary should convert float to packed decimal before Easytrieve FILE definitions consume records. Document conversion formulas and test edge cases: very large amounts, negative zero semantics, and NaN—which have no direct Easytrieve literal equivalent. Reject or flag non-numeric float states in staging files rather than letting them enter P fields as garbage nybbles.

Common Misconceptions

  1. Assuming N 9 2 is floating because it lacks COMP-3— it is still fixed zoned decimal.
  2. Using division without ROUNDED then expecting exact currency cents.
  3. Declaring eight-byte B hoping it behaves like Java double—it does not without IEEE layout.
  4. Storing rates as A character strings and expecting silent numeric IF—convert or use N/P.

Explain It Like I'm Five

Floating point is like writing really big or really tiny numbers with a shortcut that sometimes rounds wrong—like saying about a million instead of counting every penny. Easytrieve uses piggy banks that count every penny exactly in special slots—no shortcuts. That is slower for rocket science math but perfect for paying everyone the right amount on payday.

Exercises

  1. Define a tax rate field with four decimal positions and VALUE 0.0825.
  2. Explain why SUM on payroll prefers P over hypothetical float.
  3. Describe one approach when input files contain COBOL COMP-1.
  4. Write assignment computing 15% of GROSS with ROUNDED into P 5 2.
  5. List all DEFINE type codes and note which support decimal positions.

Quiz

Test Your Knowledge

1. Does Easytrieve DEFINE support a native floating-point type letter?

  • No—use fixed decimal N P B with decimal positions
  • Yes—type F for float
  • Yes—type G for IEEE
  • Only in SCREEN activities

2. Financial amounts in Easytrieve typically use:

  • P packed with decimal positions
  • Alphabetic A only
  • No numeric types
  • Hex literals only

3. To store a rate like 0.0825 precisely you might use:

  • P 3 4 or similar fixed decimal
  • A 10 without digits
  • Type I 8
  • Comment lines

4. COBOL COMP-1 floating items in Easytrieve files require:

  • Special handling outside standard P N I—often binary overlay and external conversion
  • Automatic type F mapping
  • TYPE A only
  • No DEFINE possible

5. Fixed decimal arithmetic on mainframes favors Easytrieve because:

  • Predictable digit precision for money and reports
  • Float is faster for all payroll
  • SUM ignores decimals
  • P cannot have decimal positions
Published
Read time12 min
AuthorMainframeMaster
Reviewed by MainframeMaster teamVerified: Broadcom Easytrieve 11.6 DEFINE types—no native IEEE float; fixed decimal N P B U ISources: Broadcom Easytrieve Report Generator 11.6 DEFINE Statement, Describe Files and FieldsApplies to: Easytrieve numeric modeling without floating point