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

Reply via email to