GCC Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
fortran

Fortran: Implement list-directed read for hexadecimal floating-point formats.

Fortran's list-directed READ now supports hexadecimal floating-point input.

This commit adds support for reading hexadecimal floating-point numbers using list-directed input in Fortran. Previously, the READ(*,*) statement could not correctly parse formats like 0x1.2p3. The implementation in libgfortran now parses these hexadecimal float formats and then delegates validation to the convert_real function. A new test case, EXformat_5.F90, has been added to verify this functionality.

In Details

The libgfortran io/list_read.c now correctly parses hexadecimal floating-point formats (like those specified by Z or X format codes, or C99's 0x...p... notation) during list-directed input. The parse_real function is enhanced to recognize these formats, and then invokes convert_real to handle the conversion and validation of the numerical value. This extends the input capabilities beyond standard decimal or exponential notation for floating-point numbers.

For Context
list-directed input
A format-free input method in Fortran (specified by * in READ(*,*)) where the compiler infers the data type and structure of the input values based on their appearance.
hexadecimal floating-point format
A representation of floating-point numbers using a hexadecimal base for the significand (mantissa) and often a binary exponent, typically denoted with a p or P separator (e.g., 0x1.8p-3).
libgfortran
The runtime library for the GNU Fortran compiler (gfortran), providing support for I/O, intrinsic functions, and other language features.
parse_real
A function within the Fortran runtime library responsible for interpreting character strings representing real (floating-point) numbers.
convert_real
A function likely responsible for validating and converting a parsed representation of a real number into the compiler's internal floating-point format.
Filed Under: fortrangfortraniofloating-point