Bug in color sensor twig sample code

Hi, in the color sensor twig sample code on garden.seeedstudio.com/index.php … nsor_v0.9b I think the line indicated below is a bug:

void calculate_xy() { X=(-0.14282)*red+(1.54924)*green+(-0.95641)*blue; Y=(-0.32466)*red+(1.57837)*green+(-0.73191)*blue; Z=(-0.68202)*red+(0.77073)*green+(0.56332)*blue; x=X/(X+Y+Z); y=Y/(X+Y+Z); ---------------bug--> if((X>0)&&(Y>0)&&(Z>0)) { Serial.println("The x,y value is"); Serial.println(x,2); Serial.println(y,2); } else Serial.println("Error,the value overflow"); }

This always prints “overflow” when looking at a bright red color. If you put red=1 and green+blue=0 into the formula you will see that X, Y, and Z will all be negative, so this is normal operation rather than an overflow. It works fine if you just remove this test.