projects
/
libfirm
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
call optimize_cf() to delete dead-code that might arise after cond_eval
[libfirm]
/
ir
/
be
/
test
/
kahansum.c
1
#include <stdio.h>
2
3
float kahanSum(const float A[], int n) {
4
float sum = 0.0, C = 0.0, Y, T;
5
int i;
6
7
for (i = 0; i < n; ++i) {
8
Y = A[i] - C;
9
T = sum + Y;
10
C = T - sum - Y;
11
sum = T;
12
}
13
return sum;
14
}
15
16
int main()
17
{
18
float test[] = { 1,2,3,4,5,6,7,8,9};
19
printf("Result: %f\n", kahanSum(test, sizeof(test)/sizeof(float)));
20
21
return 0;
22
}