Path: utzoo!mnetor!geac!torsqnt!tmsoft!list-injector From: steve@cohort.UUCP (Steve Bird) Newsgroups: can.usrgroup Subject: C code (fwd) Message-ID: <9002280838.AA01415@cohort.uucp> Date: 28 Feb 90 13:38:06 GMT Reply-To: Steve Bird Distribution: ont Lines: 35 X-Mailer: ELM [version 2.2 PL7] Forwarded message: >From steve Fri Nov 24 21:46:23 1989 Subject: C code To: evan@telly (Evan Leibovitch) Date: Fri, 24 Nov 89 21:46:23 EST From: Steve Bird X-Mailer: ELM [version 2.2 PL7] Here's another interesting piece. /* floaterr.c--demonstrates round-off error */ # include main() { float a,b; b = 2.0e20 + 1.0; a = b - 2.0e20; printf("%f \n",a); } When compiled the program returns the number 4008175468544.000000 . Now when the program is modified to read : /* floaterr.c--demonstrates round-off error */ # include main() { float a,b; b = 2.0e20 + 1.0; a = 2.0e20; printf("%f \n",b - a); } The program returns 0.000000 . Why ?