Altera_Forum
Honored Contributor
11 years agoAdding two uint4
Hi, I'm struggling with adding int4 data. I want to be able to add two 96b numbers (what implies adding with carry) in my kernel and I came up with this code:
uint4 Add(uint4 a, uint4 b){
ulong c = {0};
c = (ulong)a+(ulong)b;
for(int i=1; i<3; i++){
c = (ulong)a+(ulong)b + (c>>32);
}
return (uint4)(c,c,c,0);
} However, I noticed that typecasting significantly increases my resource usage. I'd appreciate if anyone could help me with finding a better solution.