This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]