473,396 Members | 1,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

long integer multiplication

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

Apr 29 '07 #1
9 10851
helPlease wrote:
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.
Apr 29 '07 #2
helPlease said:
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.
Apr 29 '07 #3

"Joe Estock" <je*****@NOSPAMnutextonline.comwrote in message
news:sf******************************@insightbb.co m...
helPlease wrote:
>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
Apr 29 '07 #4
Wade Ward said:

<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.
Apr 29 '07 #5
Joe Estock <je*****@NOSPAMnutextonline.comwrites:
helPlease wrote:
>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) ks***@mib.org <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"
Apr 29 '07 #6
helPlease wrote:
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;}
Apr 29 '07 #7
Keith Thompson wrote:
Joe Estock <je*****@NOSPAMnutextonline.comwrites:
>helPlease wrote:
>>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.
Apr 29 '07 #8
"helPlease" wrote:
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
Apr 29 '07 #9
helPlease wrote:
>
hello !! Can anybody provide me an algorithm or C code for long
integer multiplication.It's urgent.
(a + b) * (c + d) = ac + ad + bc + bd

and you can make improvements.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
<http://kadaitcha.cx/vista/dogsbreakfast/index.html>
cbfalconer at maineline dot net
--
Posted via a free Usenet account from http://www.teranews.com

Apr 29 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: I.V. Aprameya Rao | last post by:
hi i have been wondering, how does python store its very long integers and perform aritmetic on it. i needed to implement this myself and was thinking of storing the digits of an integer in a...
17
by: Christopher Dyken | last post by:
Hi group, I'm trying to implement two routines to handle 32x32-bits and 64x64-bits signed integer multiplication on a 32 bits machine in C. It easy to find descriptions of non-signed...
20
by: GS | last post by:
The stdint.h header definition mentions five integer categories, 1) exact width, eg., int32_t 2) at least as wide as, eg., int_least32_t 3) as fast as possible but at least as wide as, eg.,...
25
by: junky_fellow | last post by:
Is there any way by which the overflow during addition of two integers may be detected ? eg. suppose we have three unsigned integers, a ,b, c. we are doing a check like if ((a +b) > c) do...
9
by: luke | last post by:
Hi everybody, please, can someone explain me this behaviour. I have the following piece of code: long long ll; unsigned int i = 2; ll = -1 * i; printf("%lld\n", ll);
5
by: helPlease | last post by:
By long integer i mean very large number(say of 20 digits).If i store it in a character array then what mechanism shud i follow to multiply two such numbers.Could Booth's algo. be applied.Or if...
4
by: Mamluk Caliph | last post by:
The following code executes as I would expect on gcc: #include <inttypes.h> #include <stdio.h> int main(int argc, char **argv){ uint16_t apa = 10000; uint16_t kaka = 7000;...
28
by: Bartc | last post by:
From an article about implementing a C99 to C90 translator... How does someone use integer arithmetic of at least 64 bits, and write in pure C90? As I understand C90 (the standard is very...
14
by: Default User | last post by:
Hi, If I have three 64 bit integers and I want to do this operation on them: x*y/z Lets say that what we are multiplying by (y) is offset by what we are dividing by (z) so that the final...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.