projects
/
libfirm
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
added compile only flag to eccp (-c)
[libfirm]
/
ir
/
be
/
test
/
kahansum.c
1
float kahanSum(const float A[], int n) {
2
float sum = 0.0, C = 0.0, Y, T;
3
int i;
4
5
for (i = 0; i < n; ++i) {
6
Y = A[i] - C;
7
T = sum + Y;
8
C = T - sum - Y;
9
sum = T;
10
}
11
return sum;
12
}
13
14
int main()
15
{
16
float test[] = { 1,2,3,4,5,6,7,8,9};
17
printf("Result: %f\n", kahanSum(test, sizeof(test)/sizeof(float)));
18
19
return 0;
20
}