Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!uwvax!rhesus!uwmacc!jwp From: jwp@uwmacc.UUCP (Jeffrey W Percival) Newsgroups: comp.unix.wizards,comp.lang.c Subject: Incorrect subtraction in C program Message-ID: <1573@uwmacc.UUCP> Date: Mon, 1-Jun-87 19:13:04 EDT Article-I.D.: uwmacc.1573 Posted: Mon Jun 1 19:13:04 1987 Date-Received: Wed, 3-Jun-87 02:48:12 EDT Organization: UWisconsin-Madison Academic Comp Center Lines: 34 Keywords: vax, C, 4.3BSD Xref: mnetor comp.unix.wizards:2553 comp.lang.c:2293 I have a problem I have distilled down into a short C program. The problem is that when I subtract a tiny number from 1, I get 1 (the right answer) on a VAX 780 running 4.3BSD, but I get 0 (the wrong answer) on a MicroVAX running 4.3BSD. Here's the program: --------------------------------------------------- #include #include main() { double a, b, c, d, e; a = 1.000000; b = 0.000001; c = 0.193113; d = (b * c); e = a - d; fprintf(stdout, "a=%f, b=%f, c=%f, d=%f, e=%f\n", a, b, c, d, e); exit(0); } ---------------------------------------------------------- and here's the MicroVAX output followed by the VAX 780 output: ------------------------------------------------------- a=1.000000, b=0.000001, c=0.193113, d=0.000000, e=0.000000 a=1.000000, b=0.000001, c=0.193113, d=0.000000, e=1.000000 So, the MicroVAX says that (a-d) is 0, not 1. What's the deal here? -- Jeff Percival (jwp@salvax1)