This is the mail archive of the gcc-bugs@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]

scanf floating point bug?


Dear gnu team,

I cannot correctly input floating point numbers via scanf. I am using gcc 2.95.3-4 as it is distributed by cygnus solutions. My machine is a Pentium Win98 computer. Please find attached the requested *.i files from the following command line. I would be happy to get some ideas.

Regards, Marold

Command line:

$ gcc -v --save-temps scanf_float.c

Source code:

#include <stdio.h>

int main(void)
{
      int i;
      float flt;
      double dbl;

      printf("Enter int: ");     /* 55 */
      scanf("%i", &i);
      printf("i=%i\n", i);        /* 55, ok */
     
      printf("Enter float: ");     /* 5.543 */
      scanf("%f", &flt);
      printf("flt=%f\n", flt);    /* 5543.000000, ERROR */

      printf("Enter double: ");      /* 5.543 */
      scanf("%lf", &dbl);
      printf("dbl=%f\n", dbl);    /* 5543.000000, ERROR */
      
      return 0;
}

scanf_float.i

scanf_float.out


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