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 @@ -261,9 +261,10 @@ flags |= decimal::AlwaysSign; } bool noLeadingSpaces{editWidth == 0}; + int scale{edit.modes.scale}; // 'kP' value if (editWidth == 0) { // "the processor selects the field width" if (edit.digits.has_value()) { // E0.d - if (editDigits == 0) { // E0.0 + if (editDigits == 0 && scale <= 0) { // E0.0 significantDigits = 1; } } else { // E0 @@ -274,7 +275,6 @@ } bool isEN{edit.variation == 'N'}; bool isES{edit.variation == 'S'}; - int scale{edit.modes.scale}; // 'kP' value int zeroesAfterPoint{0}; if (isEN) { scale = IsZero() ? 1 : 3;