[Bug c/36737] New: Wrong results from floating-point multiplication by 10

aremo at ngi dot it gcc-bugzilla@gcc.gnu.org
Sat Jul 5 09:11:00 GMT 2008


A C program, compiled without optimization, which does repeated multiplications
by 10 on a float number (0.2008) outputs incorrect results.

I know about the "most often reported non-bug", but since the K&R specifies
that FLT_DIG (decimal digits of precision) must be at least 6, I still consider
this to be a possible bug.

The program was compiled with command line: 'gcc --save-temps ~/mathbug.c'

-----BEGIN PROGRAM OUTPUT-----
nn = 2.008000
nn = 20.079998
nn = 200.799988
nn = 2007.999878
nn = 20079.998047
nn = 200799.984375
nn = 2007999.875000
------END PROGRAM OUTPUT------

-----BEGIN VERSION INFO-----
~> gcc -v
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-libgcj-multifile
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk
--disable-dssi --enable-plugin
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic
--host=i386-redhat-linux
Thread model: posix
gcc version 4.1.2 20070626 (Red Hat 4.1.2-14)
~> uname -a
Linux xyzzy.local 2.6.18-92.1.6.el5 #1 SMP Wed Jun 25 12:46:39 EDT 2008 i686
athlon i386 GNU/Linux
------END VERSION INFO------


-- 
           Summary: Wrong results from floating-point multiplication by 10
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: aremo at ngi dot it
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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



More information about the Gcc-bugs mailing list