[flang-commits] [flang] 567462b - [flang] Correct kP scaling on F output
peter klausler via flang-commits
flang-commits at lists.llvm.org
Mon Oct 5 14:06:45 PDT 2020
Author: peter klausler
Date: 2020-10-05T13:58:42-07:00
New Revision: 567462b48eba1c2d286ce97117994463f4535d2e
URL: https://github.com/llvm/llvm-project/commit/567462b48eba1c2d286ce97117994463f4535d2e
DIFF: https://github.com/llvm/llvm-project/commit/567462b48eba1c2d286ce97117994463f4535d2e.diff
LOG: [flang] Correct kP scaling on F output
The sign of the scaling factor was misinterpreted for output
as meaning what it does for input. To be correct, they
should cancel each other out.
print '(1P,F4.3)', 1. ! printed 0.1 but should print 10.0
Differential revision: https://reviews.llvm.org/D88610
Added:
Modified:
flang/runtime/edit-output.cpp
flang/unittests/Runtime/hello.cpp
Removed:
################################################################################
diff --git a/flang/runtime/edit-output.cpp b/flang/runtime/edit-output.cpp
index bae3606689e7..145e01044144 100644
--- a/flang/runtime/edit-output.cpp
+++ b/flang/runtime/edit-output.cpp
@@ -277,8 +277,8 @@ bool RealOutputEditing<binaryPrecision>::EditFOutput(const DataEdit &edit) {
return EmitPrefix(edit, converted.length, editWidth) &&
io_.Emit(converted.str, converted.length) && EmitSuffix(edit);
}
- int scale{IsZero() ? -1 : edit.modes.scale};
- int expo{converted.decimalExponent - scale};
+ int scale{IsZero() ? 1 : edit.modes.scale}; // kP
+ int expo{converted.decimalExponent + scale};
if (expo > extraDigits && extraDigits >= 0) {
extraDigits = expo;
if (!edit.digits.has_value()) { // F0
diff --git a/flang/unittests/Runtime/hello.cpp b/flang/unittests/Runtime/hello.cpp
index bcd3bb448318..d17c98e74c13 100644
--- a/flang/unittests/Runtime/hello.cpp
+++ b/flang/unittests/Runtime/hello.cpp
@@ -232,7 +232,7 @@ int main() {
{"(G32.17E4,';')", " 1.0000000000000000 ;"},
{"(1P,E32.17,';')", " 1.00000000000000000E+00;"},
{"(1PE32.17,';')", " 1.00000000000000000E+00;"}, // no comma
- {"(1P,F32.17,';')", " 0.10000000000000000;"},
+ {"(1P,F32.17,';')", " 10.00000000000000000;"},
{"(1P,G32.17,';')", " 1.0000000000000000 ;"},
{"(ES32.17,';')", " 1.00000000000000000E+00;"},
{"(2P,E32.17,';')", " 10.0000000000000000E-01;"},
More information about the flang-commits
mailing list