473,788 Members | 2,807 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 10888
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*****@NOSPAM nutextonline.co mwrote in message
news:sf******** *************** *******@insight bb.com...
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*****@NOSPAM nutextonline.co mwrites:
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_Keit h) 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(l ong int x, long int y) { return x*y;}
Apr 29 '07 #7
Keith Thompson wrote:
Joe Estock <je*****@NOSPAM nutextonline.co mwrites:
>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.securityfoc us.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
2049
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 list. however this would be very slow for operations like division etc.
17
8029
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 multiplication, however, I haven't found any good descriptions for the signed counterpart. Does any of you have a good reference for this topic? Thanks in advance,
20
9176
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., int_fast32_t 4) integer capable of holding a pointer, intptr_t 5) widest integer in the implementation, intmax_t Is there a valid motivation for having both int_least and int_fast?
25
6279
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 something;
9
3953
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
743
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 anybody has any suggestions then please tell.
4
3807
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; uint32_t mazarin;
28
4983
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 elusive), long int is guaranteed to be at least 32 bits only. So, do people rely on their known compiler limits, use clunky emulations, or do not bother with 64 bits when writing ultra-portable code?
14
5171
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 answer will fit in a 64-bit integer. Let me simplify it by using unsigned chars (8 bits):
0
9498
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10373
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10118
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9969
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5403
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4074
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.