Geometrical question

Can anybody explain me, where am I wrong?

Definitions:

ac, ab, bc - corresponding lengths

acb - angle between (ca) and (cb)

Such code:

...

acb = acos((ac*ac + bc*bc - ab*ab) / 2.0 / ac / bc);

..

gets AC.

Such code:

...

double spv(point x1, point x2, point y1, point y2){

int i;

double res = 0;

for (i=1; i<=n; i++){

res += (x2.coord[i] - x1.coord[i]) * (y2.coord[i] - y1.coord[i]);

}

return res;

}

...

acb = acos(spv(c,a,c,b)/ac/bc);...

...

gets WA25.

I had always thought that these two fragments must yield the same result. Why don't they?