I use Kahan summation algorithm:
inline void KahanSum(float value, float & sum, float & correction) { float term = value - correction; float temp = sum + term; correction = (temp - sum) - term; sum = temp; } float KahanSum(const float * ptr, size_t size) { float sum = 0, correction = 0; for(size_t i = 0; i < size; ++i) KahanSum(ptr[i], sum, correction); return sum; } It works fine if it is compiled with using of MSVS, but it has a big computing error when I use GCC.
Where is the trouble here?
size_t?