[flang-commits] [PATCH] D128396: [flang][runtime] Improve G0 output editing
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Thu Jun 23 11:27:49 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdf6afee9859f: [flang][runtime] Improve G0 output editing (authored by klausler).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D128396/new/
https://reviews.llvm.org/D128396
Files:
flang/runtime/edit-output.cpp
flang/unittests/Runtime/NumericalFormatTest.cpp
Index: flang/unittests/Runtime/NumericalFormatTest.cpp
===================================================================
--- flang/unittests/Runtime/NumericalFormatTest.cpp
+++ flang/unittests/Runtime/NumericalFormatTest.cpp
@@ -394,9 +394,9 @@
{"(E62.55,';')",
" 0.1000000000000000055511151231257827021181583404541015625E+"
"00;"},
- {"(E0.0,';')", "0.E+00;"},
+ {"(E0.0,';')", ".1E+00;"},
{"(E0.55,';')",
- "0.1000000000000000055511151231257827021181583404541015625E+"
+ ".1000000000000000055511151231257827021181583404541015625E+"
"00;"},
{"(E0,';')", ".1E+00;"},
{"(F58.55,';')",
@@ -491,7 +491,7 @@
"701797267771758512566055119913150489110145103786273816725095"
"583738973359899366480994116420570263709027924276754456522908"
"75386825064197182655334472656250-323;"},
- {"(G0,';')", ".5-323;"},
+ {"(G0,';')", ".5E-323;"},
{"(E757.750,';')",
" 0."
"494065645841246544176568792868221372365059802614324764425585"
@@ -586,7 +586,7 @@
"408698898317506783884692609277397797285865965494109136909540"
"61364675687023986783152906809846172109246253967285156250-"
"307;"},
- {"(G0,';')", ".22250738585072014-307;"},
+ {"(G0,';')", ".22250738585072014E-307;"},
}},
{// greatest finite
0x7fefffffffffffffuLL,
@@ -616,7 +616,7 @@
"090389328944075868508455133942304583236903222948165808559332"
"123348274797826204144723168738177180919299881250404026184124"
"8583680000+306;"},
- {"(G0,';')", ".17976931348623157+309;"},
+ {"(G0,';')", ".17976931348623157E+309;"},
}},
};
Index: flang/runtime/edit-output.cpp
===================================================================
--- flang/runtime/edit-output.cpp
+++ flang/runtime/edit-output.cpp
@@ -199,7 +199,7 @@
}
*--exponent = expo < 0 ? '-' : '+';
if (edit.expoDigits || edit.IsListDirected() || exponent + 3 == eEnd) {
- *--exponent = edit.descriptor == 'D' ? 'D' : 'E'; // not 'G'
+ *--exponent = edit.descriptor == 'D' ? 'D' : 'E'; // not 'G' or 'Q'
}
length = eEnd - exponent;
return overflow ? nullptr : exponent;
@@ -264,9 +264,7 @@
if (editWidth == 0) { // "the processor selects the field width"
if (edit.digits.has_value()) { // E0.d
if (editDigits == 0) { // E0.0
- editWidth = 7; // -.0E+ee
- } else {
- editWidth = editDigits + 6; // -.666E+ee
+ significantDigits = 1;
}
} else { // E0
flags |= decimal::Minimize;
@@ -485,7 +483,7 @@
int significantDigits{
edit.digits.value_or(BinaryFloatingPoint::decimalPrecision)}; // 'd'
if (editWidth > 0 && significantDigits == 0) {
- return edit; // Gw.0 -> Ew.0 for w > 0
+ return edit; // Gw.0Ee -> Ew.0Ee for w > 0
}
int flags{0};
if (edit.modes.editingFlags & signPlus) {
@@ -498,7 +496,10 @@
}
int expo{IsZero() ? 1 : converted.decimalExponent}; // 's'
if (expo < 0 || expo > significantDigits) {
- return edit; // Ew.d
+ if (editWidth == 0 && !edit.expoDigits) { // G0.d -> G0.dE0
+ edit.expoDigits = 0;
+ }
+ return edit; // Ew.dEe
}
edit.descriptor = 'F';
edit.modes.scale = 0; // kP is ignored for G when no exponent field
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128396.439476.patch
Type: text/x-patch
Size: 3602 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220623/65d0ed9d/attachment.bin>
More information about the flang-commits
mailing list