Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!husc6!linus!philabs!pwa-b!mmintl!franka From: franka@mmintl.UUCP Newsgroups: comp.lang.c Subject: Re: Floating Point Comparisons Message-ID: <2074@mmintl.UUCP> Date: Wed, 1-Apr-87 17:57:44 EST Article-I.D.: mmintl.2074 Posted: Wed Apr 1 17:57:44 1987 Date-Received: Sun, 5-Apr-87 10:16:57 EST References: <842@vaxb.calgary.UUCP> Reply-To: franka@mmintl.UUCP (Frank Adams) Distribution: na Organization: Multimate International, E. Hartford, CT Lines: 18 In article <842@vaxb.calgary.UUCP> lomow@calgary.UUCP writes: >While it is clear that comparing floating point numbers using the == > relation is dangerous, are there similar problems with using the > other relational operators such as <, <=, >, >= ? Only in cases involving near-equality. For example, don't write: double a; for (a = 0.0; a < 1.0; a += 0.1) ... because you don't know what will happen the 11th time through. A good general rule is: don't make comparisons between floats where you care which result is returned when the numbers are very close. Frank Adams ihnp4!philabs!pwa-b!mmintl!franka Ashton-Tate 52 Oakland Ave North E. Hartford, CT 06108