diff --git a/flang/runtime/edit-output.cpp b/flang/runtime/edit-output.cpp --- a/flang/runtime/edit-output.cpp +++ b/flang/runtime/edit-output.cpp @@ -531,7 +531,12 @@ return EditEorDOutput(edit); } int expo{converted.decimalExponent}; - if (expo < 0 || expo > BinaryFloatingPoint::decimalPrecision) { + // The decimal precision of 16-bit floating-point types is very low, + // so use a reasonable cap of 6 to allow more values to be emitted + // with Fw.d editing. + static constexpr int maxExpo{ + std::max(6, BinaryFloatingPoint::decimalPrecision)}; + if (expo < 0 || expo > maxExpo) { DataEdit copy{edit}; copy.modes.scale = 1; // 1P return EditEorDOutput(copy);