[prev in list] [next in list] [prev in thread] [next in thread]
List: freebsd-wireless
Subject: comparing floating points via "==" or "!="
From: smithi () nimnet ! asn ! au (Ian Smith)
Date: 2011-12-02 3:55:57
Message-ID: 20111202142524.V3548 () sola ! nimnet ! asn ! au
[Download RAW message or body]
On Thu, 1 Dec 2011, Alexander Best wrote:
> On Wed Nov 30 11, Igor Mozolevsky wrote:
> > On 30 November 2011 22:44, Alexander Best <arundel@freebsd.org> 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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic