This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/15374] New: computational error


bug report


gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)

here is a simple programme:
/////////////////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include<stdlib.h>
#include <math.h>
#include <float.h>

int main (void)
{

 
		 
	if (   (0.9*(  100.0 / (1.0/9.0) -  sin(10)/ (1.0/9.0)*0.0  )   - 0.9*(  100.0
/ (1.0/9.0)))    ==0   )
	
		{
		
	  	printf("it  equal 0\n");
		
		}
		
		 
	if (   (0.9*(  100.0 / (1.0/9.0) -  sin(10)/ (1.0/9.0)*0.0  )   - 0.9*(  100.0
/ (1.0/9.0)))    !=0   )
	
		{
		
	  	printf("it  does not equal 0\n");
		printf("The error is %e\n",  (.1*(  100.0 / (1.0/9.0) -  sin(10)/
(1.0/9.0)*0.0  )   - .1*(  100.0 / (1.0/9.0)))  );
		}	 
	
	
		 
}


/////////////////////////////////////////////////////////////////////////////////////////

1.  when I compile it with gcc under redhat linux9.0, the result is :

it  does not equal 0
The error is 4.996004e-15

2.but when I compile it with VC++6.0  under window2000, the result is :
it  equal 0

I want to know the reason why the results are different.

thanks!!!!!!!!!!!!!!!!!!

-- 
           Summary: computational error
           Product: gcc
           Version: 3.2.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tiangaoshuijing at 163 dot com
                CC: gcc-bugs at gcc dot gnu dot org


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]