Closed GoogleCodeExporter closed 9 years ago
Windows 7 64-bit, CPU: AMD Athlon X2
Original comment by Azimu...@gmail.com
on 12 Feb 2012 at 8:46
No bug, finite precision math is tricky and highly dependent on the order in
which operations happen. The two loops are "mathematically" equivalent but not
computationally equivalent.
To get the same solution in both loops simply sum up the batch of 50 first,
then add it to s2:
double sum = 0;
for(int i=0; i<50; i++)
{
sum += p1[i]*p2[i];
}s2 += sum;
Original comment by peter.ab...@gmail.com
on 14 Feb 2012 at 8:56
thanks
Original comment by Azimu...@gmail.com
on 15 Feb 2012 at 10:37
Original issue reported on code.google.com by
Azimu...@gmail.com
on 12 Feb 2012 at 8:33