[flang][runtime] Emit "0.0E+0" for (1PG0.0) editing of 0.0
authorPeter Klausler <pklausler@nvidia.com>
Mon, 27 Jun 2022 21:22:31 +0000 (14:22 -0700)
committerPeter Klausler <pklausler@nvidia.com>
Wed, 29 Jun 2022 18:42:39 +0000 (11:42 -0700)
When a scale factor is in effect, respect it for G0.0 output editing.

Differential Revision: https://reviews.llvm.org/D128761

flang/runtime/edit-output.cpp

index 7dc60cb..57641dd 100644 (file)
@@ -261,9 +261,10 @@ bool RealOutputEditing<binaryPrecision>::EditEorDOutput(const DataEdit &edit) {
     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 RealOutputEditing<binaryPrecision>::EditEorDOutput(const DataEdit &edit) {
   }
   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;