This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/4434: the value of float epsilon is wrong
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/4434: the value of float epsilon is wrong
- From: nejataydin at superonline dot com
- Date: Mon, 1 Oct 2001 16:10:42 +0300
>Number: 4434
>Category: c++
>Synopsis: the value of float epsilon is wrong
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Mon Oct 01 06:16:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Nejat AYDIN
>Release: 3.0.1
>Organization:
>Environment:
System: Linux localhost.localdomain 2.2.16-22 #1 Tue Aug 22 16:16:55 EDT 2000 i586 unknown
Architecture: i586
host: i586-pc-linux-gnu
build: i586-pc-linux-gnu
target: i586-pc-linux-gnu
configured with: ../src/gcc-3.0.1/configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man
>Description:
The command line is simply "g++ eps.cc" and there is no compiler output.
Below is the source code (the file "eps.cc")
/************************ Source Code ***********************/
#include <iostream>
#include <limits>
using namespace std;
int main()
{
cout << "float epsilon == "
<< numeric_limits<float>::epsilon() << endl;
cout << "double epsilon == "
<< numeric_limits<double>::epsilon() << endl;
cout << "long double epsion == "
<< numeric_limits<long double>::epsilon() << endl;
}
/***************** End of Source Code *********************/
Output of the program is
float epsilon == 2
double epsilon == 2.22045e-16
long double epsion == 1.0842e-19
which is the float epsilon is an obviously wrong value,
while other epsilon values are plausible.
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: