GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
cobol

GCOBOL displays COMP-1/-2 in IBM format when dialect is set

GCOBOL now correctly displays COMP-1 and COMP-2 floating-point variables using IBM's specified format when the `-dialect ibm` option is active.

This commit modifies GCOBOL to adopt IBM’s specified display format for COMP-1 and COMP-2 floating-point variables when the compiler is invoked with the -dialect ibm option. Previously, GCOBOL used its own idiosyncratic display, but now it adheres to the COBOL specification where COMP-1 displays as if it had a picture clause of -.9(8)E-99, and COMP-2 as -.9(17)E-99. This ensures greater compatibility and predictability for COBOL developers targeting IBM systems.

In Details

COBOL COMP-1 and COMP-2 are internal representations for single-precision and double-precision floating-point numbers, respectively. The display format for these types is often implementation-defined. This change to genapi.cc, genutil.cc, and libgcobol.cc introduces a mechanism to detect the -dialect ibm compiler flag and, when active, to alter the format_for_display_internal function to output COMP-1 and COMP-2 values according to IBM's PICTURE clause specifications. This involves adjusting the precision and exponent representation during conversion from internal binary f…

For Context

COBOL is an older programming language still used in many business applications. When COBOL programs display numbers, especially floating-point numbers (which can have decimal points), the way they're formatted can sometimes differ between different versions or 'dialects' of COBOL. This commit changes GCOBOL, a particular implementation of the COBOL compiler, to be more compatible with IBM's version of COBOL. Specifically, when you tell GCOBOL to act like an IBM compiler (using a special command-line option), it will now display single-precision (COMP-1) and double-precision (COMP-2) floating-point numbers in the exact format that an IBM COBOL compiler would. This is important for ensuring that programs work and look the same across different COBOL environments.

Filed Under: cobolibmcompatibilityfloating-point