From owner-freebsd-wireless@FreeBSD.ORG Fri Dec 2 03:55:49 2011 Return-Path: Delivered-To: freebsd-wireless@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DDBAB106566C; Fri, 2 Dec 2011 03:55:49 +0000 (UTC) (envelope-from smithi@nimnet.asn.au) Received: from sola.nimnet.asn.au (paqi.nimnet.asn.au [115.70.110.159]) by mx1.freebsd.org (Postfix) with ESMTP id 4AC418FC0A; Fri, 2 Dec 2011 03:55:49 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by sola.nimnet.asn.au (8.14.2/8.14.2) with ESMTP id pB23XhkU091352; Fri, 2 Dec 2011 14:33:43 +1100 (EST) (envelope-from smithi@nimnet.asn.au) Date: Fri, 2 Dec 2011 14:33:43 +1100 (EST) From: Ian Smith To: Alexander Best In-Reply-To: <20111201000243.GB44877@freebsd.org> Message-ID: <20111202142524.V3548@sola.nimnet.asn.au> References: <20111130224422.GA36424@freebsd.org> <20111201000243.GB44877@freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: freebsd-wireless@freebsd.org Subject: Re: comparing floating points via "==" or "!=" X-BeenThere: freebsd-wireless@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussions of 802.11 stack, tools device driver development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Dec 2011 03:55:49 -0000 On Thu, 1 Dec 2011, Alexander Best wrote: > On Wed Nov 30 11, Igor Mozolevsky wrote: > > On 30 November 2011 22:44, Alexander Best wrote: > > > > > i played a bit with the gcc -Wfloat-equal warning and noticed that inside > > > sys/dev/ath/ath_rate/sample/tx_schedules.h, a lot of comparisons of floating > > > points are happening ("=="). is there a better way to deal with this? > > > > as opposed to (abs(a-b) < tolerance)? > > fabs(3) actually, or some other way, e.g. described in: > > http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm Bookmarked, thanks. Very good article, and I never knew IEEE floats could be compared as integers! OT for wireless, but very useful for some astronomical stuff I'm working on .. in Pascal, no less :) cheers, Ian