public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* double error
@ 2003-01-31 18:44 Bob Hou
  2003-01-31 19:01 ` Bob Hou
  2003-01-31 19:07 ` Andreas Conz
  0 siblings, 2 replies; 4+ messages in thread
From: Bob Hou @ 2003-01-31 18:44 UTC (permalink / raw)
  To: gcc, gcc, yhou

Hi,
I have the following simple code and expect the results are all the
same.
However the output is following: (The code is compiled with gcc under
Redhat8.0. )

The result is : 0
The result is : 0
The result is : -2.22045e-15

The code is also tested on MS VS6.0
and it give the same answers (zero).

Could you tell me whether it's a bug or I did sth wrong?
Thanks,

/*--------------- test.c---------------------------*/
#include<stdio.h>

int main()
{
  double fi = 0.7509;
  double fj = 100.0;
  double fk, fk1, fk2 ;
   fk = fj*fi - fj*fi;
   fk1 = 0.7509*100.0 - 0.7509*100.0;
   fk2 = fj*fi - 0.7509*100.0;
   printf("The result is : %g\n", fk);
   printf("The result is : %g\n", fk1);
   printf("The result is : %g\n", fk2);

   return 0;
}
/*-----------------end-----------------------------*/

--
__________________________________________________________
Dr. Bob (Yuqian) Hou
Certre for Vision Research
Rm0002B, CSB
York University
4700 Keele Street
North York, Ontario
Canada M3J 1P3

Tel: (416) 736-2100 ext. 66117
Fax: (416) 736-5814


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-01-31 18:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-31 18:44 double error Bob Hou
2003-01-31 19:01 ` Bob Hou
2003-01-31 19:07 ` Andreas Conz
2003-01-31 19:12   ` Andreas Conz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).