MainframeMaster

FS (Floating Sign) Format

In DFSORT, FS (also written CSF) stands for signed numeric with optional leading floating sign. Unlike ZD (zoned decimal), where the sign is fixed in the last byte, or PD (packed decimal), where the sign is in the rightmost nibble, FS allows the sign character to appear anywhere to the left of the digits. DFSORT finds the first character that is not a decimal digit (0–9) when scanning from right to left and treats it as the sign: "-" means negative, and any other character (e.g. "+" or blank) means positive. Everything to the left of that sign is ignored. This format matches data produced by FORTRAN, PL/I, and COBOL display formats such as PIC ++9, PIC +999, PIC ---9, and PIC ZZZZ. This page explains what FS is, how the sign is determined, when to use it instead of ZD or PD, and how to specify it in SORT FIELDS, INCLUDE/OMIT, and build statements.

Data Types & Formats
Progress0 of 0 lessons

What FS Means

FS tells DFSORT: "this field is a signed number, but the sign is not in a fixed position." The format is often shown as s d…d: an optional sign s to the left of the digits d…d. The key rule: the first non–decimal digit (i.e. not 0–9) found when scanning from right to left is treated as the sign. If that character is "-", the value is negative; otherwise (including "+", blank, or any other character) the value is positive. Any characters to the left of that sign are ignored when forming the numeric value. So the sign "floats" in the sense that it can appear in different column positions depending on how many leading blanks or plus signs are present.

How the Sign Is Determined

DFSORT parses the field from right to left. It collects decimal digits (0–9) and stops when it hits the first non-digit. That character is the sign indicator. Only "-" (minus) is treated as negative; everything else—including "+", blank, space, or any other character—is treated as positive. So:

FS interpretation examples
Value in fieldTreated as
34+34 (blank or + to left of digits = positive)
+34+34
00034+34
-003-3
--1234-1234
1234+1234
+01234+1234
0+0

This behavior allows one format to handle FORTRAN-style fixed columns, PL/I edited pictures, and COBOL display fields where the sign might be leading separate, leading overpunch, or in a dedicated position that varies by implementation.

Syntax: SORT FIELDS and Other Statements

Use FS (or CSF) wherever you specify a format for a numeric field:

text
1
SORT FIELDS=(start,length,FS,direction)
  • start — Starting position of the field (1-based).
  • length — Length in bytes of the entire field (including sign and any leading/trailing characters).
  • FS (or CSF) — Format: signed numeric with optional leading floating sign.
  • direction — A for ascending, D for descending.

Example: sort by a 10-byte field at position 20 that contains values like " +123" or " -456", ascending:

text
1
SORT FIELDS=(20,10,FS,A)

You can use FS in INCLUDE/OMIT when comparing the field to a constant, and in INREC/OUTREC when the build refers to a floating-sign field. The length you give is the full length of the area that contains the number and its optional sign and padding.

FS vs ZD vs PD

Choosing the right format avoids wrong sort order or comparison results:

When to use FS vs ZD vs PD
FormatMeaningTypical use
FS (CSF)Signed numeric, sign can float (first non-digit from right = sign).FORTRAN, PL/I, COBOL display with separate or floating sign (PIC ++9, PIC ---9, etc.).
ZDZoned decimal: one digit per byte, sign in last byte (low-order 4 bits).COBOL PIC S9(n) DISPLAY, standard EBCDIC zoned.
PDPacked decimal: two digits per byte (except last has sign nibble).COBOL COMP-3, binary-packed decimal.

If your data has a fixed zoned layout with sign in the last byte, use ZD. If it is packed decimal, use PD. If the sign can appear in a variable position with leading blanks or plus/minus, use FS so that DFSORT parses the value correctly.

Data Types That Produce FS-Compatible Data

IBM documentation states that FS (CSF) encompasses data produced by several FORTRAN, PL/I, and COBOL formats. Examples (with a width of 4 for illustration):

  • FORTRAN: I4, G4.0, SP,I4, SP,I4.3, S,I4.3
  • PL/I: F(4), P'S999', P'SSS9', P'---9'
  • COBOL: PIC ++9, PIC +999, PIC ++++, PIC ---9, PIC ----, PIC ZZZZ

In these cases the numeric value may have a leading or embedded sign (plus, minus, or blank for positive) and possibly leading zeros or spaces. FS interprets them consistently by the right-to-left rule.

When to Use FS

Use FS when the field has floating sign
Use caseReason
FORTRAN fixed-column numeric outputSign and leading spaces vary by value; FS parses right-to-left.
PL/I edited numeric (e.g. P'SSS9')Sign position can vary; FS handles it.
COBOL PIC with floating sign (++, +999, ---9, ZZZZ)Display format with optional leading sign; FS matches.
Legacy files with variable sign positionWhen you cannot rely on fixed zoned (ZD) or packed (PD) layout.

When Not to Use FS

  • Standard zoned decimal (PIC S9(n) DISPLAY, sign in last byte) — Use ZD. The layout is fixed; ZD is the correct and often more efficient choice.
  • Packed decimal (COMP-3) — Use PD. FS is for character/display representation, not packed.
  • Binary (COMP, COMP-4) — Use BI or FI. FS is for display-style numeric strings.
  • Pure character keys (names, codes) — Use CH. FS is for numeric interpretation.

FS in INCLUDE and OMIT

When you filter records with INCLUDE or OMIT and the condition involves a numeric comparison, specify the format of the field. If that field has a floating sign, use FS so that the comparison uses the parsed numeric value. For example, to include only records where the value in positions 1–10 is greater than zero:

text
1
INCLUDE COND=(1,10,FS,GT,+0)

The constant +0 is the numeric zero; GT means greater than. DFSORT will parse each record's 1–10 as FS and compare the result to 0.

Explain It Like I'm Five

Imagine a number written on a whiteboard with a plus or minus in front, but sometimes there are extra spaces. We read from the right: we find the digits (0–9), and the first thing that isn't a digit is the sign. If it's a minus, the number is negative; if it's a plus or a space, the number is positive. We ignore any extra stuff to the left. FS is the rule that tells the sort program to read numbers that way—so " +34" and " 34" and "00034" all count as the same positive number 34, and "-003" is minus 3. That way we can sort them in the right order even when the sign and spaces are in different places.

Exercises

  1. Write a SORT FIELDS statement to sort on a 12-byte floating-sign field at position 5, ascending. Use FS.
  2. What numeric value does FS give for " -99 "? Explain using the right-to-left rule.
  3. Your file has a 10-byte field that sometimes looks like " +123" and sometimes " -45". Which format (FS, ZD, or PD) should you use in SORT FIELDS, and why?
  4. Write an INCLUDE COND to keep only records where the FS field in positions 20–29 is less than or equal to 100.

Quiz

Test Your Knowledge

1. What does FS (or CSF) mean in DFSORT?

  • Floating-point single precision (4-byte IEEE float)
  • Signed numeric with optional leading floating sign: the sign character can appear to the left of the digits anywhere in the field
  • Fixed-length string
  • Field separator

2. How does FS determine whether a value is positive or negative?

  • By the first byte only
  • By the last byte only
  • The first non-decimal digit (not 0-9) found going from right to left is treated as the sign; "-" means negative, any other character (e.g. + or blank) means positive
  • FS always treats the field as positive

3. Which COBOL or language data types does FS handle?

  • Only COMP-3
  • Only COMP
  • Display formats with floating sign: e.g. COBOL PIC ++9, PIC +999, PIC ---9, FORTRAN I4/G4.0, PL/I F(4) or P'SSS9'
  • Only binary integers

4. When should you use FS instead of ZD?

  • Always use FS for numeric data
  • Use FS when the numeric field has a floating sign (sign in variable position) and optional leading/trailing characters; use ZD when the field is standard zoned decimal with sign in the last byte only
  • ZD is only for packed decimal
  • FS is only for floating-point numbers

5. What value does FS treat " 00034 " as?

  • Zero
  • +34 (digits 3 and 4; first non-digit from right is the space before 3, treated as positive)
  • -34
  • Invalid