Review Request: KColorSpace::KHCY::KHCY(const & QColor) constructor floating point precision error
Oswald Buddenhagen
ossi at kde.org
Tue Jun 23 06:52:18 BST 2009
On Mon, Jun 22, 2009 at 07:15:39PM -0400, Michael Pyne wrote:
> On Monday 22 June 2009 17:53:54 Michael Kreitzer wrote:
> > I considered that as well. The only thing that worries me is IEEE 754 on
> > x86 seems woefully unreliable for direct comparisons if you're not trying
> > to do something very simple (e.g. prevent a divide by zero).
>
> In all fairness, floating point on pretty much any platform is not suitable
> for comparing to equality with anything but 0.0. For floating point if you
> must compare something being equal to another value you should allow some
> tolerance (i.e. is it within 1e-5, not is it exactly equal to something).
> I think the best answer in this case is to ensure as much as possible,
> comparisons are done against 0.0 (i.e. don't do if (a == b), but do c = a - b;
> if(c == 0.0) )
>
i really have to wonder what the technical foundation of that idea is,
because to me it doesn't make any sense.
More information about the kde-core-devel
mailing list