ohhh myyy gawd c++ issues!!!
Posted: Sat Oct 27, 2012 11:08 pm
I have one int array and one float array, both of size 9. I multiply them by each other. I have two ways of doing it that I thought were equal, but give different results!
As you can see, the first one uses a for-loop, and the second one unrolls it all out. When I use the second one, I get the results I expect, and when I use the first one ( the for-loop ) I get weird results and I can't figure out why.
The pixels array is int, and the kernel array is float. Is it just me, or is there something wrong going on?
Code: Select all
for (int a = 0; a < 9; a++)
{
blue2 += ((pixels[a] &blue) * kernel[a]);
}
blue2 = (((pixels[0] &blue) * kernel[0]) + ((pixels[1] &blue) * kernel[1]) + ((pixels[2] &blue) * kernel[2]) + ((pixels[3] &blue) * kernel[3]) + ((pixels[4] &blue) * kernel[4]) + ((pixels[5] &blue) * kernel[5]) + ((pixels[6] &blue) * kernel[6]) + ((pixels[7] &blue) * kernel[7]) + ((pixels[8] &blue) * kernel[8]));
The pixels array is int, and the kernel array is float. Is it just me, or is there something wrong going on?