# long integer multiplication

Discussion in 'C Programming' started by helPlease, Apr 29, 2007.

hello !! Can anybody provide me an algorithm or C code for long
integer multiplication.It's urgent.

helPlease, Apr 29, 2007

2. ### Joe EstockGuest

> hello !! Can anybody provide me an algorithm or C code for long
> integer multiplication.It's urgent.
>

Please do your own homework or at least attempt to do your own homework
and if you get stuck then post your code. Attempting to solve the
problem yourself and asking for help when you are stuck at least shows
that you are dedicated to learning and not just looking for a free
handout. Since you have declared that this is urgent I suggest you start
writing code immediately.

Joe Estock, Apr 29, 2007

3. ### Wade WardGuest

"Joe Estock" <> wrote in message
news:...
>> hello !! Can anybody provide me an algorithm or C code for long
>> integer multiplication.It's urgent.
>>

>
> Please do your own homework or at least attempt to do your own homework
> and if you get stuck then post your code. Attempting to solve the problem
> yourself and asking for help when you are stuck at least shows that you
> are dedicated to learning and not just looking for a free handout. Since
> you have declared that this is urgent I suggest you start writing code
> immediately.

long long x;
int y = 0;
y = y *(int)x;
I think that might be legal.
--
WW

Wade Ward, Apr 29, 2007
4. ### Richard HeathfieldGuest

> hello !! Can anybody provide me an algorithm or C code for long
> integer multiplication.It's urgent.

long int f(long int i, long int j)
{
return i * j; /* but beware of overflow */
}

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.

Richard Heathfield, Apr 29, 2007
5. ### Richard HeathfieldGuest

<snip>
> long long x;
> int y = 0;
> y = y *(int)x;
> I think that might be legal.

It isn't. The value of x is indeterminate, so the result of the explicit
conversion is undefined.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.

Richard Heathfield, Apr 29, 2007
6. ### Keith ThompsonGuest

Joe Estock <> writes:
>> hello !! Can anybody provide me an algorithm or C code for long
>> integer multiplication.It's urgent.

>
> Please do your own homework or at least attempt to do your own
> homework and if you get stuck then post your code. Attempting to solve
> the problem yourself and asking for help when you are stuck at least
> shows that you are dedicated to learning and not just looking for a
> free handout. Since you have declared that this is urgent I suggest
> you start writing code immediately.

Perhaps he should start thinking about algorithms immediately;
depending on how much thought he's already given to the problem, it
may not yet be time to start coding.

I will give a hint: if by "long integer" he means the C type "long
int", then he'll find the "*" operator to be quite helpful. If he
means something else, he should say so rather than wasting what little
time he has posing poorly phrased questions.

--
Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

Keith Thompson, Apr 29, 2007
7. ### Martin AmbuhlGuest

> hello !! Can anybody provide me an algorithm or C code for long
> integer multiplication.It's urgent.

inline long int long_multiply(long int x, long int y) { return x*y;}

Martin Ambuhl, Apr 29, 2007
8. ### Joe EstockGuest

Keith Thompson wrote:
> Joe Estock <> writes:
>>> hello !! Can anybody provide me an algorithm or C code for long
>>> integer multiplication.It's urgent.

>> Please do your own homework or at least attempt to do your own
>> homework and if you get stuck then post your code. Attempting to solve
>> the problem yourself and asking for help when you are stuck at least
>> shows that you are dedicated to learning and not just looking for a
>> free handout. Since you have declared that this is urgent I suggest
>> you start writing code immediately.

>
> Perhaps he should start thinking about algorithms immediately;
> depending on how much thought he's already given to the problem, it
> may not yet be time to start coding.
>
> I will give a hint: if by "long integer" he means the C type "long
> int", then he'll find the "*" operator to be quite helpful. If he
> means something else, he should say so rather than wasting what little
> time he has posing poorly phrased questions.
>

I agree, however do to his wording and the phrase "it's urgent" I
concluded that he was/is looking for a quick grade. If he was not
attempting to have someone else solve his homework question for him then
he should have been more descriptive regarding what he was looking for,
perhaps by stating what it is he hoped to accomplish. I'm by no means an
expert at the C language, or any other language for that matter, but
I've been in the game for several years now and each time I see someone
trying to take the easy way out for a good grade It disgusts me because
those are the ones that the truly knowledgeable developers will have to
come in and clean up after. I don't mind working with code even if it's
originally from someone else, but I do strongly dislike fixing code from
a fresh college graduate that only graduated because he copied the code
from someone else or had someone write it for him purely so that he
could graduate and have a degree in CS.

Joe Estock, Apr 29, 2007
9. ### osmiumGuest

> Can anybody provide me an algorithm or C code for long
> integer multiplication.It's urgent.

Take a look at this article. Perhaps it will still make sense if you read
the word "nibble" as "a C char". Then think back to some of the things you
learned about multiply in elementary school and then what you might do with
an array of char.

http://en.wikipedia.org/wiki/Binary-coded_decimal

osmium, Apr 29, 2007