From kde-core-devel Tue Jun 23 20:59:12 2009 From: Michael Pyne Date: Tue, 23 Jun 2009 20:59:12 +0000 To: kde-core-devel Subject: Re: Review Request: KColorSpace::KHCY::KHCY(const & QColor) Message-Id: <200906231659.19429.mpyne () kde ! org> X-MARC-Message: https://marc.info/?l=kde-core-devel&m=124579080419190 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--nextPart2048757.YWs9K9VU9i" --nextPart2048757.YWs9K9VU9i Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable On Tuesday 23 June 2009 01:52:18 Oswald Buddenhagen wrote: > On Mon, Jun 22, 2009 at 07:15:39PM -0400, Michael Pyne wrote: > > 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 =3D=3D b), but do= c =3D a > > - b; if(c =3D=3D 0.0) ) > > i really have to wonder what the technical foundation of that idea is, > because to me it doesn't make any sense. Well if all you're really worried about is dividing against zero then you c= an=20 compare against 0.0 (which is really the only equality comparison you can d= o=20 on floating point since it is exact and so are its conversions to different= =20 forms). You do need to make sure that the value you're dividing by is the value you= 're=20 comparing against though, which is why I recommended using the named tempor= ary=20 variable. I suppose this doesn't work if the division will be performed at= a=20 lower precision (which from my understanding of x86, could happen when usin= g=20 the FPU), since what is not quite zero as an 80-bit double could be convert= ed=20 to a 64-bit zero. If we're really that worried about it I think Olivier's solution would be j= ust=20 fine (i.e. qFuzzyCompare). Regards, - Michael Pyne --nextPart2048757.YWs9K9VU9i Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.11 (GNU/Linux) iQIcBAABCAAGBQJKQUInAAoJEAuvDJx7aunyDysP/ihgb/4ZycEtWnDjD92LQ9IU e8/dxuTs/37+QGfy8LW2qp/4Oh56ALf/EVNQENO3IaJwKRoxk3MRJ2xBpwMfgGnq XfjA1izk8wtz7JASr377mzILudi3TYd7hHRQV7oGNoPEusvU4t8Stl/QMjyjeskH ECRy4G564NYlEjTEkRIc4bBSnavukgmLFC9/QbigsJLq/GaQzCacSLeezfC3cn6W Sba11oo4PFz4xtzJx3lZUl6eUX9QLUh5S/b+3D3ZsCrtgI1VFff4tjea9rTe8tzR gdiLnuGFIX6vxYUv8RHVBDU3X4d8KvTtAoWcMOi0AQQs5G29hzPosSRlX9YZQTNS XyAT1CQoLSUqWB1x1l3Ys0QqMwrfvyEfsWVKDdoP20+G6Hn0804xcshsjnNTY9Yc ieVv1r5hel3vPsArtBnk5u5yg9iWerruX13eGtfDbdX4yfTFwbO7n0LCQzDASt7N 4WX7b2BIF+ET2eu9m6e/yjgx6iaQsQPkCdI2PU0Xajfzp8MAXezFMsTeFGEzMl4u wuNCjudoz/d8XhV+JYVPA4tNk2bS3KNlXmbo6iApltrNu2fmZIFv0S2L0JjZbCWh LpO6kxFseRK6Dh3fUkIb0EMltV/cSE/6TjmE/8NizpNR+lYRn3YPiIH4yT4jaJi4 8/Oh4KmYnmaGBPNcPhAh =sumC -----END PGP SIGNATURE----- --nextPart2048757.YWs9K9VU9i--