diff options
author | Dominique d'Humieres <dhumieres.dominique@free.fr> | 2020-07-24 20:27:53 +0200 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2020-07-24 20:47:47 +0200 |
commit | aa7e7eff5ec165dc8463a0e74309801b15d1feda (patch) | |
tree | 237c249a7dcaafe8c18ac9b32062f9b5b4eb208c /gcc | |
parent | 05e0971bcf94a481cbfa2731484f024a67dbd4a5 (diff) | |
download | gcc-aa7e7eff5ec165dc8463a0e74309801b15d1feda.zip gcc-aa7e7eff5ec165dc8463a0e74309801b15d1feda.tar.gz gcc-aa7e7eff5ec165dc8463a0e74309801b15d1feda.tar.bz2 |
PR 93567, G edit descriptor uses E instead of F editing in rounding mode UP.
The switch between FMT_E and FMT_F is based on the absolute value.
Set r=0 for rounding toward zero and r = 1 otherwise.
If (exp_d - m) == 1 there is no rounding needed.
libgfortran/ChangeLog:
PR fortran/93567
* io/write_float.def (determine_en_precision): Fix switch between
FMT_E and FMT_F.
gcc/testsuite/ChangeLog:
PR fortran/93567
* gfortran.dg/round_3.f08: Add test cases.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/gfortran.dg/round_3.f08 | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/gcc/testsuite/gfortran.dg/round_3.f08 b/gcc/testsuite/gfortran.dg/round_3.f08 index 57d8339..4a0a692 100644 --- a/gcc/testsuite/gfortran.dg/round_3.f08 +++ b/gcc/testsuite/gfortran.dg/round_3.f08 @@ -110,6 +110,30 @@ program pr48615 call checkfmt("(RU,E17.1)", nearest(2.0, 1.0), " 0.3E+01") call checkfmt("(RD,E17.1)", nearest(3.0, -1.0), " 0.2E+01") + call checkfmt("(G12.2)", 99.0, " 99. ") + call checkfmt("(G12.2)", 99.5, " 0.10E+03") + call checkfmt("(G12.2)", 100.0, " 0.10E+03") + call checkfmt("(G12.2)", -99.0, " -99. ") + call checkfmt("(G12.2)", -99.5, " -0.10E+03") + call checkfmt("(G12.2)", -100.0, " -0.10E+03") + call checkfmt("(RU,G12.2)", 99.0, " 99. ") ! pr93567 + call checkfmt("(RU,G12.2)", 99.01, " 0.10E+03") + call checkfmt("(RU,G12.2)", -99.0, " -99. ") + call checkfmt("(RU,G12.2)", -99.01, " -99. ") + call checkfmt("(RU,G12.2)", -100.01, " -0.10E+03") + call checkfmt("(RU,G12.4)", 99.0 , " 99.00 ") + call checkfmt("(RU,G12.4)", 99.01, " 99.02 ") + call checkfmt("(RD,G12.2)", 99.0, " 99. ") + call checkfmt("(RD,G12.2)", 99.01, " 99. ") + call checkfmt("(RD,G12.2)", 100.01, " 0.10E+03") + call checkfmt("(RD,G12.2)", -99.0, " -99. ") + call checkfmt("(RD,G12.2)", -99.01, " -0.10E+03") + call checkfmt("(RD,G12.2)", -100.00, " -0.10E+03") + call checkfmt("(Rz,G12.2)", 99.01, " 99. ") + call checkfmt("(Rz,G12.2)", 100.01, " 0.10E+03") + call checkfmt("(Rz,G12.2)", -99.01, " -99. ") + call checkfmt("(Rz,G12.2)", -100.01, " -0.10E+03") + contains subroutine checkfmt(fmt, x, cmp) character(len=*), intent(in) :: fmt @@ -119,6 +143,6 @@ contains write(s, fmt) x if (s /= cmp) STOP 1 - !if (s /= cmp) print "(a,1x,a,' expected: ',1x)", fmt, s, cmp + !if (s /= cmp) print "(a,1x,a,' expected: ',1x,a)", fmt, s, cmp end subroutine end program |