Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!husc6!seismo!rochester!pt.cs.cmu.edu!sei.cmu.edu!firth From: firth@sei.cmu.edu.UUCP Newsgroups: comp.lang.c Subject: Re: floating point == Message-ID: <907@aw.sei.cmu.edu.sei.cmu.edu> Date: Thu, 9-Apr-87 09:09:44 EST Article-I.D.: aw.907 Posted: Thu Apr 9 09:09:44 1987 Date-Received: Sat, 18-Apr-87 02:36:17 EST References: <429@euclid.warwick.UUCP> Sender: netnews@sei.cmu.edu Reply-To: firth@bd.sei.cmu.edu.UUCP (PUT YOUR NAME HERE) Organization: Carnegie-Mellon University, SEI, Pgh, Pa Lines: 18 In article <429@euclid.warwick.UUCP> steve@warwick.UUCP (Steve Rumsby) writes: >OK, now that we have decided that floating point == doesn't make a lot of sense >and that feq(x, y, fuzz) is the way to go, does anybody have an *efficient* >implementation of feq. I have an application spending between 10% and 15% of >its time doing feq, and I would really like to speed up this routine. Any >volunteers? Allow me to pass on this disgusting hack with no recommendation except that, when one of my students found it, it spread like wildfire: . floating subtract y from x . extract the exponent field of the result . integer compare it to "small", where small = log2(eps) (don't forget the bias in the representation) And you don't even have to worry about the sign of (x-y). To make this a closed subroutine, replace that last compare by a subtract. The sign of the result tells all. Four instructions on a Vax.