re PR libfortran/59771 (Cleanup handling of Gw.0 and Gw.0Ee format)
2014-01-19 Jerry DeLisle <jvdelisle@gcc.gnu> Dominique d'Humieres <dominiq@lps.ens.fr> PR libfortran/59771 PR libfortran/59774 PR libfortran/59836 * io/write_float.def (output_float): Fix wrong handling of the Fw.0 format. (output_float_FMT_G_): Fixes rounding issues with -m32. Co-Authored-By: Dominique d'Humieres <dominiq@lps.ens.fr> From-SVN: r206785
This commit is contained in:
parent
cdafab3de6
commit
32aeb94ab1
@ -1,3 +1,13 @@
|
||||
2014-01-19 Jerry DeLisle <jvdelisle@gcc.gnu>
|
||||
Dominique d'Humieres <dominiq@lps.ens.fr>
|
||||
|
||||
PR libfortran/59771
|
||||
PR libfortran/59774
|
||||
PR libfortran/59836
|
||||
* io/write_float.def (output_float): Fix wrong handling of the
|
||||
Fw.0 format.
|
||||
(output_float_FMT_G_): Fixes rounding issues with -m32.
|
||||
|
||||
2014-01-11 Jerry DeLisle <jvdelisle@gcc.gnu>
|
||||
Dominique d'Humieres <dominiq@lps.ens.fr>
|
||||
Steven G. Kargl <kargl@gcc.gnu.org>
|
||||
|
@ -373,7 +373,7 @@ output_float (st_parameter_dt *dtp, const fnode *f, char *buffer, size_t size,
|
||||
updown:
|
||||
|
||||
rchar = '0';
|
||||
if (w > 0 && d == 0 && p == 0)
|
||||
if (ft != FMT_F && nbefore == 0 && w > 0 && d == 0 && p == 0)
|
||||
nbefore = 1;
|
||||
/* Scan for trailing zeros to see if we really need to round it. */
|
||||
for(i = nbefore + nafter; i < ndigits; i++)
|
||||
@ -386,13 +386,14 @@ output_float (st_parameter_dt *dtp, const fnode *f, char *buffer, size_t size,
|
||||
do_rnd:
|
||||
|
||||
if (nbefore + nafter == 0)
|
||||
/* Handle the case Fw.0 and value < 1.0 */
|
||||
{
|
||||
ndigits = 0;
|
||||
if (nzero_real == d && digits[0] >= rchar)
|
||||
{
|
||||
/* We rounded to zero but shouldn't have */
|
||||
nzero--;
|
||||
nafter = 1;
|
||||
nbefore = 1;
|
||||
digits--;
|
||||
digits[0] = '1';
|
||||
ndigits = 1;
|
||||
}
|
||||
@ -1018,13 +1019,14 @@ output_float_FMT_G_ ## x (st_parameter_dt *dtp, const fnode *f, \
|
||||
int d = f->u.real.d;\
|
||||
int w = f->u.real.w;\
|
||||
fnode newf;\
|
||||
GFC_REAL_ ## x rexp_d, r = 0.5;\
|
||||
GFC_REAL_ ## x exp_d, r = 0.5, r_sc;\
|
||||
int low, high, mid;\
|
||||
int ubound, lbound;\
|
||||
char *p, pad = ' ';\
|
||||
int save_scale_factor, nb = 0;\
|
||||
bool result;\
|
||||
int nprinted, precision;\
|
||||
volatile GFC_REAL_ ## x temp;\
|
||||
\
|
||||
save_scale_factor = dtp->u.p.scale_factor;\
|
||||
\
|
||||
@ -1043,10 +1045,13 @@ output_float_FMT_G_ ## x (st_parameter_dt *dtp, const fnode *f, \
|
||||
break;\
|
||||
}\
|
||||
\
|
||||
rexp_d = calculate_exp_ ## x (-d);\
|
||||
if ((m > 0.0 && ((m < 0.1 - 0.1 * r * rexp_d) || (rexp_d * (m + r) >= 1.0)))\
|
||||
exp_d = calculate_exp_ ## x (d);\
|
||||
r_sc = (1 - r / exp_d);\
|
||||
temp = 0.1 * r_sc;\
|
||||
if ((m > 0.0 && ((m < temp) || (r >= (exp_d - m))))\
|
||||
|| ((m == 0.0) && !(compile_options.allow_std\
|
||||
& (GFC_STD_F2003 | GFC_STD_F2008))))\
|
||||
& (GFC_STD_F2003 | GFC_STD_F2008)))\
|
||||
|| d == 0)\
|
||||
{ \
|
||||
newf.format = FMT_E;\
|
||||
newf.u.real.w = w;\
|
||||
@ -1066,10 +1071,9 @@ output_float_FMT_G_ ## x (st_parameter_dt *dtp, const fnode *f, \
|
||||
\
|
||||
while (low <= high)\
|
||||
{ \
|
||||
volatile GFC_REAL_ ## x temp;\
|
||||
mid = (low + high) / 2;\
|
||||
\
|
||||
temp = (calculate_exp_ ## x (mid - 1) * (1 - r * rexp_d));\
|
||||
temp = (calculate_exp_ ## x (mid - 1) * r_sc);\
|
||||
\
|
||||
if (m < temp)\
|
||||
{ \
|
||||
|
Loading…
Reference in New Issue
Block a user