4
Contributors
4
Replies
6
Views
8 Years
Discussion Span
Last Post by Ancient Dragon
1

> Can anyone share concept
I assume you know how to add say 16 and 18 together to get 34

I mean, once you've figured out the concept of 'carry', whether you're storing each element of your overall number in a character, or byte, or long really doesn't make a bean of difference.

Votes + Comments
Good to see you posting again :)
1
for(i  =  0; i < 2; i++)
{
rslt1 = ( a[i] & 0x7fffffffu ) + ( b[i] & 0x7fffffffu ) + carry;//first add 31lsb bits
carry= rslt1 >> 31;// 32 th bit is carry
rslt2 = (a[i] >> 31) + (b[i] >> 31) + carry; //add this carry with 32th bit's of operands
carry = rslt2 >> 1; //msb of answer is the carry from 32 bit addition
rslt1 = rslt1 & 0x7fffffffu;
rslt2 = rslt1 + (rslt2 << 31);//lsb of that answer is the 32th bit of original answer
result[i] = rslt2;//result stored in to an array
}

//Any doubt call me MFM india(kerala) Mob:<MOBILE NUMBER SNIPPED>

Edited by peter_budo: Keep It Organized - Do not ask anyone (member or moderator) for help by email or PM

Votes + Comments
cool post
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.