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.
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.
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.
12345DEFINE 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
| Concept | Easytrieve approach | Notes |
|---|---|---|
| Fractional rate | P or N with high decimal count | P 3 4 for four decimal places |
| Currency | P 5 2 typical | Matches COMP-3 V99 |
| Large integer count | I 4 or I 8 | Whole numbers only |
| Very small epsilon | Scale up (micro-units as int) | Store millionths as integer I |
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.
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 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.
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.
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.
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.
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.
1. Does Easytrieve DEFINE support a native floating-point type letter?
2. Financial amounts in Easytrieve typically use:
3. To store a rate like 0.0825 precisely you might use:
4. COBOL COMP-1 floating items in Easytrieve files require:
5. Fixed decimal arithmetic on mainframes favors Easytrieve because: