|
From: Per W. <pw...@ia...> - 2008-04-02 13:17:13
|
You either don't (with normal 32-bit numbers you don't have to think about
any carry for so small products...)
If this is a school work, or you are implementing a big-number library
working in decimal, you just have to keep an intermediate variable
'carry'.
carry = 0;
while (digit-columns to add) {
column_sum = carry + digit + digit + digit + digit + ...;
carry = column_sum / 10;
column_sum %= 10;
emit_digit(column_sum);
}
if (carry) emit_digit(carry);
/pwm
On Wed, 2 Apr 2008, Kenneth Chung wrote:
>
> Hi All,
>
> Consider a multiplication of the form
>
>
> 9 9 9
> x 9 9 9
> ------
> 8 9 9 1
> 8 9 9 1
> 8 9 9 1
> -----------
> 9 9 8 0 0 1 <----result
>
> How do I program the result line using C code especially when the sum of numbers has 2 digits let say 10, 20 then the first digit which is the 1 or 2 has to be added to next column for next sum?
>
> Thanks for your help.
>
> regards,
> Kenneth
> _________________________________________________________________
> Search for local singles online @ Lavalife - Click here
> http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Flavalife9%2Eninemsn%2Ecom%2Eau%2Fclickthru%2Fclickthru%2Eact%3Fid%3Dninemsn%26context%3Dan99%26locale%3Den%5FAU%26a%3D30290&_t=764581033&_r=email_taglines_Search_OCT07&_m=EXT
|