opensubscriber
   Find in this group all groups
 
Unknown more information…

l : lcms-user@lists.sourceforge.net 17 October 2009 • 1:39PM -0400

[Lcms-user] Floating point equality comparisons
by Ethan Hansen

REPLY TO AUTHOR
 
REPLY TO GROUP






Several of the conversion routines in cmspcs.c perform explicit comparisons
of double values to 0. Depending on the compiler used and the optimization
parameters, these comparisons can be unreliable. A floating point number may
not be *exactly* 0 - or any other specific number for that matter - although
that was the intent of the program and/or programmer.



Suggested changes:

26a27,28
> #include <float.h>
>

183c185
<        if (xyz -> X == 0 && xyz -> Y == 0 && xyz -> Z == 0)
---
>        if (fabs(xyz -> X) <= DBL_EPSILON && fabs(xyz -> Y) <= DBL_EPSILON
&& fabs(xyz -> Z) <= DBL_EPSILON)

296c298
<        if (L==0.0) {
---
>        if (fabs(L) <= DBL_EPSILON) {

480c482
<     if (a == 0 && b == 0)
---
>     if (fabs(a) <= DBL_EPSILON && fabs(b) <= DBL_EPSILON)


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Lcms-user mailing list
Lcms-user@list...
https://lists.sourceforge.net/lists/listinfo/lcms-user

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.