We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Is it possible to have a 64bit or 96 Integer addition in C?
yes, but you need to write a routine to do it. Erik
I just think i have to divide my 64bit long word into a low and high 32bit value. First the low addition, then the high addition. But how to manage the carry from low to high? I need a very fast routine. In Assembler i could use the ADD command for low value, then ADC for high word. But in C?
Check whether your compiler supports 64-bit long-longs. Otherwise: "But how to manage the carry from low to high?" For unsigned arithmetic 32-bit addition should "wrap" (overflow) modulo 2^32 predictably, which you can detect and use as the carry.
For unsigned arithmetic 32-bit addition should "wrap" (overflow) modulo 2^32 predictably, which you can detect and use as the carry. i hope you can show me a little example, sorry i'am an absoulute beginner in C :-)
Which particular ARM compiler are you using? Further to this thread http://www.keil.com/forum/docs/thread7615.asp I think that GCC supports the 'long long' type to give 64 bits? You may find that your compiler is similar. You will, of course, need to check in the Manual
Oops - Dan had already said that!
"i hope you can show me a little example"
struct U64 { unsigned long msl; unsigned long lsl; }; struct U64 U64_sum(struct U64 augend, struct U64 addend) { struct U64 sum; sum.msl = augend.msl + addend.msl; sum.lsl = augend.lsl + addend.lsl; if (sum.lsl < augend.lsl) /* Carry? */ ++sum.msl; return sum; }