Edit report at https://bugs.php.net/bug.php?id=64736&edit=1
ID: 64736 Updated by: s...@php.net Reported by: s...@php.net Summary: Incorrect calculation in gdColorMatch -Status: Feedback +Status: Open Type: Bug Package: GD related Operating System: Linux PHP Version: 5.5Git-2013-04-29 (Git) Block user comment: N Private report: N New Comment: In C, "^" is the bitwise exclusive OR operator (and has lower precedence than "+"). Pow() is the power function. Previous Comments: ------------------------------------------------------------------------ [2013-04-30 05:21:35] paj...@php.net That's the classic distance calculation in the RGB cube, does ^ not have precedence with the compiler you use? It should (or has in all platforms I use) :). ------------------------------------------------------------------------ [2013-04-29 23:05:06] s...@php.net Description: ------------ Compilations warnings in gd_crop.c flag a potential calculation issue in gdColorMatch: /home/cjones/php-5.5/ext/gd/libgd/gd_crop.c:340: warning: suggest parentheses around arithmetic in operand of ^ /home/cjones/php-5.5/ext/gd/libgd/gd_crop.c:340: warning: suggest parentheses around arithmetic in operand of ^ The code at line 340 is: const double dist_perc = sqrt(dist / (255^2 + 255^2 + 255^2)); The denominator is currently evaluated as 253. Was it instead intended be (3 * (255 * 255)) == 195075 ? ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=64736&edit=1