[gfortran] PATCH PR20480 zero is written with non-zero exponent

Tobias Schlüter tobias.schlueter@physik.uni-muenchen.de
Wed Mar 16 14:58:00 GMT 2005


François-Xavier Coudert wrote:
> @@ -411,7 +411,8 @@ output_float (fnode *f, double value, in
>      case FMT_EN:
>        /* The exponent must be a multiple of three, with 1-3 digits before
>          the decimal point.  */
> -      e--;
> +      if (value != 0.0)
> +        e--;
>        if (e >= 0)
>         nbefore = e % 3;
>        else

I would prefer if you special cased e == 0 in the code immediately following
the line you changed, because it seems clearer to me, i.e. write
    case FMT_EN:
      /* The exponent must be a multiple of three, with 1-3 digits before
	 the decimal point.  */
      if (value != 0.0)
        e--;
      if (e == 0)
        nbefore = 0
      else
        {
         if (e > 0)
	   nbefore = e % 3;
         else if (e < 0)
   	   {
 	     nbefore = (-e) % 3;
	     if (nbefore != 0)
	       nbefore = 3 - nbefore;
	   }
         e -= nbefore;
       }

Otherwise ok.

Thanks,
- Tobi



More information about the Gcc-patches mailing list