Compiling the following snippet

       write(*,100) 0.99999
       write(*,100) 0.999999
       write(*,100) 0.9999999
       write(*,100) 0.99999999
       write(*,100) 0.999999999
       write(*,100) 0.9999999999
 100   format((f3.0))
       end

with gcc-gfortran-4.1.1-1.fc5, I get as output

   0.
   0.
   0.
   1.
   1.
   1.


I get similar faulty output with -0.9999..., but with no other number/format
combination I have tried.
I get normal output (i.e. all 1.) with other compilers on other machines, such
as gcc-g77-3.2.2-5 on i686; moreover (if that's relevant)

#include <stdio.h>
int main()
{
  printf("%3.0f\n",0.999);
  printf("%3.0f\n",0.9999);
  printf("%3.0f\n",0.99999);
  printf("%3.0f\n",0.999999);
  printf("%3.0f\n",0.9999999);
  printf("%3.0f\n",0.99999999);
}

gives all ones too, when compiled on the same machine with gcc-4.1.1-1.fc5


-- 
           Summary: 0.99999 printed as 0. instead of 1. by format(f3.0)
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: enrico dot segre at weizmann dot ac dot il
  GCC host triplet: i686


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28354

Reply via email to