This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/29282] New: floating point precision problem
- From: "wilsonymc at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 Sep 2006 06:39:46 -0000
- Subject: [Bug c/29282] New: floating point precision problem
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The floating point precision problem can be found in the following simple ( C)
program :
***
#include <stdio.h>
int main(){
float x;
float y;
x = 0.625;
y = 0.425;
printf("x = %f x = %10.2f\n", x, x);
printf("y = %f y = %10.2f\n", y, y);
return 0;
}
***
This program compiled with GCC 4.1.1.
The expected result is:
x = 0.625000 x = 0.63
y = 0.425000 y = 0.43
However, the actual result is:
x = 0.625000 x = 0.62 <---- !!
y = 0.425000 y = 0.43
Is this problem comes due to the compiler ?
--
Summary: floating point precision problem
Product: gcc
Version: 4.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: wilsonymc at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29282