This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/50773] New: float values are printed with greater precision than the float data type has when given as an argument to printf()
- From: "momchil at xaxo dot eu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 18 Oct 2011 09:33:57 +0000
- Subject: [Bug c/50773] New: float values are printed with greater precision than the float data type has when given as an argument to printf()
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50773
Bug #: 50773
Summary: float values are printed with greater precision than
the float data type has when given as an argument to
printf()
Classification: Unclassified
Product: gcc
Version: 4.5.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: momchil@xaxo.eu
test case:
#include <stdio.h>
int
main(int argc, char *argv[])
{
float a = 268517138.f;
printf(" 268517138.f = %f\t%f\n", 268517138.f, a);
return 0;
}
output when compiling with -fexcess-precision=standard:
268517138.f = 268517138.000000 268517152.000000
output when compiling with -fexcess-precision=fast:
268517138.f = 268517152.000000 268517152.000000
reference thread: http://gcc.gnu.org/ml/gcc-help/2011-10/msg00120.html
gcc versions tested:
Using built-in specs.
COLLECT_GCC=gcc46
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc46/gcc/i386-portbld-freebsd8.1/4.6.0/lto-wrapper
Target: i386-portbld-freebsd8.1
Configured with: ./../gcc-4.6-20110101/configure --enable-lto=no --disable-nls
--libdir=/usr/local/lib/gcc46 --libexecdir=/usr/local/libexec/gcc46
--program-suffix=46 --with-as=/usr/local/bin/as --with-gmp=/usr/local
--with-gxx-include-dir=/usr/local/lib/gcc46/include/c++/
--with-ld=/usr/local/bin/ld --with-libiconv-prefix=/usr/local
--with-system-zlib --disable-rpath --prefix=/usr/local --mandir=/usr/local/man
--infodir=/usr/local/info/gcc46 --build=i386-portbld-freebsd8.1
Thread model: posix
gcc version 4.6.0 20110101 (experimental) (GCC)
Using built-in specs.
COLLECT_GCC=gcc45
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc45/gcc/i386-portbld-freebsd8.2/4.5.3/lto-wrapper
Target: i386-portbld-freebsd8.2
Configured with: ./../gcc-4.5-20110310/configure --enable-lto=yes
--with-libelf=/usr/local --disable-nls --libdir=/usr/local/lib/gcc45
--libexecdir=/usr/local/libexec/gcc45 --program-suffix=45
--with-as=/usr/local/bin/as --with-gmp=/usr/local
--with-gxx-include-dir=/usr/local/lib/gcc45/include/c++/
--with-ld=/usr/local/bin/ld --with-libiconv-prefix=/usr/local
--with-system-zlib --disable-rpath --enable-libgcj --prefix=/usr/local
--mandir=/usr/local/man --infodir=/usr/local/info/gcc45
--build=i386-portbld-freebsd8.2
Thread model: posix
gcc version 4.5.3 20110310 (prerelease) (GCC)