https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93727
--- Comment #41 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jerry DeLisle <[email protected]>: https://gcc.gnu.org/g:aacccc01d2bb3dd76ee37281b9f2f04aa9c13f5c commit r17-848-gaacccc01d2bb3dd76ee37281b9f2f04aa9c13f5c Author: Jerry DeLisle <[email protected]> Date: Sat May 23 20:28:43 2026 -0700 Fortran: [PR93727] Add EX format rounding for truncated hex mantissa Implement proper rounding of the hex mantissa in write_ex when the user specifies a d smaller than full precision. All Fortran ROUND= modes are supported: ROUND_NEAREST (ties-to-even), ROUND_COMPATIBLE (ties away from zero), ROUND_UP, ROUND_DOWN, and ROUND_ZERO. ROUND_PROCDEFINED and ROUND_UNSPECIFIED default to ROUND_NEAREST on IEEE 754 systems, consistent with the decimal format behaviour. Carry propagation handles the case where incrementing a string of trailing F hex digits reaches the integer digit; if that overflows (F รข 16) the output is normalized by setting the integer digit to 8 and incrementing the binary exponent by one. Assisted by: Claude Sonnet 4.6 PR fortran/93727 libgfortran/ChangeLog: * io/write.c (write_ex): Replace simple truncation with rounding-aware logic respecting dtp round_status. Add carry propagation and integer-digit normalization. * io/write_float.def: Change use of GFC_UINTEGER_8 to long long unsigned. gcc/testsuite/ChangeLog: * gfortran.dg/EXformat_3.F90: New test covering rounding for KIND=4, 8, 10, and 16: clear round-up, ties-to-even (truncate and round-up cases), carry propagation, and normalization. * gfortran.dg/EXrounding.F90: New test checking the various rounding modes for all kinds.
