Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!mit-eddie!uw-beaver!uw-june!entropy!dataio!bright From: bright@dataio.Data-IO.COM (Walter Bright) Newsgroups: comp.lang.c Subject: Re: Floating point equality - (nf) Message-ID: <1274@dataio.Data-IO.COM> Date: Tue, 17-Mar-87 13:41:17 EST Article-I.D.: dataio.1274 Posted: Tue Mar 17 13:41:17 1987 Date-Received: Thu, 19-Mar-87 01:08:33 EST References: <4915@brl-adm.UUCP] <16800001@qtecmuc.UUCP] Reply-To: bright@dataio.UUCP (Walter Bright) Organization: Data I/O - FutureNet Corp., Redmond, WA Lines: 17 In article <16800001@qtecmuc.UUCP] ger@qtecmuc.UUCP writes: ] I had a similar problem today, with Microsoft C 4.0 on an IBM-AT compatible. ] The compiler tries to hold the result of the floor... statement in the ] 80 bit register of the 8087 and loads just b into another ] register for the comparison, if there is no other statement inbetween. Thus ] the compiler compares the 80-bit value resulting from previous operations and ] b, which is extended from 64 bit double precision to the internal 80 bit ] format, giving a!=b. ] My question: is this behaviour legal C ???? ] Too much optimization in my eyes. From a purist standpoint, I agree with you, but not from a practical one. The code would expand considerably and would slow down a lot if the 8087 registers had to be stored and reloaded after every operation. I think it's a tradeoff that most programmers would choose, since the reason they are generating in-line 8087 code anyway is because they want maximum speed.