In DFSORT, floating-point data is stored in a binary format that represents a number using a sign, an exponent, and a mantissa (or fraction)—not as a string of decimal digits like PD or ZD. The FL format tells DFSORT to interpret the sort key as a floating-point number and compare numeric value. On the mainframe, two common families are IBM hexadecimal floating-point (used by COBOL COMP-1 and COMP-2) and IEEE binary floating-point. Support for FL and the exact byte layout (4 bytes single-precision, 8 bytes double-precision) is product-dependent. This page explains what floating-point formats are, how FL fits in, the difference between IBM hex float and IEEE, when to use FL versus PD/ZD/FS, and how to handle special values like NaN and infinity.
A floating-point value is stored as a combination of sign (positive or negative), exponent (power of the base), and mantissa (significant digits). The same bit pattern is not a simple integer or a decimal string—so comparing the bytes as character (CH) or as packed/zoned decimal (PD/ZD) does not give correct numeric order. DFSORT FL is the format that says: "interpret these bytes as a floating-point number and compare by numeric value." The exact interpretation depends on which floating-point format the bytes use (e.g. IBM hex float vs IEEE) and what your DFSORT product supports.
In IBM hexadecimal floating-point, the number is represented in a two-part form: characteristic (exponent) and fraction, with the sign in bit position 0. IBM documentation gives the example: +247 in halfword form becomes X'42F70000...' (binary: 0 1000010 111101110000000... — sign, characteristic, fraction). Negative -247 is the same with the sign bit set to 1 (X'C2F70000...'). This format is commonly used by COBOL COMP-1 (typically 4 bytes) and COMP-2 (typically 8 bytes). When your sort key is a COMP-1 or COMP-2 field, you need to use a format that interprets this layout—typically FL with length 4 or 8, if your DFSORT product supports IBM hex float.
IEEE binary floating-point (IEEE 754) uses a different layout: sign bit, exponent, and mantissa in a defined order. Single-precision is 4 bytes; double-precision is 8 bytes. Many non-mainframe systems use IEEE. If your data is generated or exchanged with systems that use IEEE float, the byte layout in the record may be IEEE. DFSORT support for IEEE (and whether FL means IBM or IEEE or is selectable) is product-dependent. Check your DFSORT manual to see which floating-point formats FL supports and how to specify length and format.
Single-precision floating-point usually occupies 4 bytes and has less range and precision than double-precision. Double-precision usually occupies 8 bytes and can represent more digits and a wider range. In COBOL, COMP-1 is typically single-precision and COMP-2 is typically double-precision. When you specify FL in SORT FIELDS, you must give the length in bytes (4 or 8) that matches the actual storage. Using the wrong length misinterprets the key and can cause wrong order or unpredictable behavior.
| Length (bytes) | Common name | COBOL example |
|---|---|---|
| 4 | Single-precision | COMP-1 |
| 8 | Double-precision | COMP-2 |
Use FL in SORT FIELDS when the key is stored in a floating-point format that your product supports:
1SORT FIELDS=(start,length,FL,direction)
Example: 8-byte double-precision float at position 20, ascending:
1SORT FIELDS=(20,8,FL,A)
Example: primary key character 1–10, secondary key 4-byte float at 11–14, ascending:
1SORT FIELDS=(1,10,CH,A,11,4,FL,A)
| Format | Effect if used on float data |
|---|---|
| CH | Byte-by-byte comparison; order is not numeric. Wrong sort order. |
| PD | Bytes interpreted as packed decimal; wrong value and order. |
| ZD | Bytes interpreted as zoned decimal; wrong value and order. |
| FI/BI | Integer interpretation; wrong for non-integer floats and scale. |
| FL | Correct: numeric float comparison (when product supports the data format). |
Conversely, do not use FL for packed decimal (use PD), zoned decimal (use ZD), or display numeric with floating sign (use FS). FL is only for binary floating-point storage.
FS (or CSF) in DFSORT means signed numeric with optional leading floating sign—a display format where the sign character can appear in variable position (e.g. " +34", "-003"). It is for character/display data from FORTRAN, PL/I, or COBOL PIC ++9. FL means floating-point—binary representation with sign, exponent, and mantissa (e.g. COMP-1, COMP-2). The names are similar but the formats are completely different. Use FS for display numbers with floating sign; use FL for binary float keys.
Floating-point standards define special bit patterns: NaN (Not a Number), negative zero (-0) and positive zero (+0), and positive and negative infinity. Different DFSORT products may sort these in different positions—for example, NaN might be ordered last, or -infinity first in ascending order. If your data can contain these values, consult your DFSORT documentation for how FL treats them so you know where they will appear in the output.
Some numbers have a decimal point, like 3.14 or 0.001. The computer can store them in a special "science" way: a little bit for plus/minus, a little bit for how big the number is (the exponent), and a little bit for the digits (the mantissa). That way it can handle very big and very small numbers. When we sort, we have to tell the sort program: "this part of the record is that kind of number," so it compares 2.5 and 10.0 correctly. That's FL. If we told it "these are just letters" (CH) or "these are packed digits" (PD), it would get the order wrong. So we use FL only when the key is really stored in that special float form.
1. What is the main difference between IBM hexadecimal floating-point and IEEE binary floating-point in DFSORT?
2. Which COBOL data types typically use floating-point storage that might require FL in SORT FIELDS?
3. Why must you not use CH for a floating-point sort key?
4. What are common lengths for FL in DFSORT?
5. What special floating-point values can affect sort order?