[cairo] Patch for comparing doubles against exact values

Antoine Azar cairo at antoineazar.com
Fri Feb 1 18:56:22 PST 2008


Hey all,

here's a patch that fixes a "bug" where we'd compare double values 
with == 0. or == 1.

We already had a macro NEARLY_ZERO that compared a value with +/- 
1/65536, I renamed it to IS_NEARLY_ZERO and added another one 
IS_EQUAL_TO to compare to any value.

I encountered this bug when out of laziness, I scaled my 
transformation matrix by 10, then reset it by scaling by 1/10 
(instead of using get/set functions). That resulted in 0.99999 values 
in the matrix instead of 1, and made the difference between going the 
pixman route or the win32 route (and a 3x performance difference).

Best,
Antoine
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0096-Removed-exact-double-comparisons-to-0-and-1-and-adde.patch
Type: application/octet-stream
Size: 5645 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20080201/5103cc07/attachment.obj 


More information about the cairo mailing list