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

Fortran: Implement EX format specifier for WRITE

The Fortran compiler now supports the EX format specifier for WRITE statements, outputting floating-point numbers in hexadecimal format.

The Fortran compiler now supports the EX format specifier for WRITE statements, as defined in Fortran 2018. This change adds the ability to output floating-point numbers in hexadecimal format for KIND=4, 8, 10, and 16 real numbers, if supported by the target architecture. Proper rounding of truncated hex float strings and the implementation of the READ functions are planned for future patches.

In Details

The EX format specifier, part of Fortran 2018, provides hexadecimal floating-point output. This patch focuses on the WRITE functionality, introducing FMT_EX token handling in io.cc and io/format.c. The new get_float_hex_string function within io/write.c extracts the bits and constructs the hexadecimal format strings. Follow-up patches will address rounding and READ implementation.

For Context

The Fortran language includes features for formatted input/output (I/O) operations, allowing developers to specify how data should be read from or written to files or the console. Format specifiers control the representation of data, such as integers, floating-point numbers, and strings. This commit introduces the 'EX' format specifier which allows floating point numbers to be displayed in hexadecimal format. This provides a way to represent the exact binary representation of floating-point values, which can be useful for debugging and ensuring portability across different systems.

Filed Under: fortranI/Oformat specifierfloating-pointhexadecimal