long integer multiplication

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

  1. helPlease

    helPlease Guest

    hello !! Can anybody provide me an algorithm or C code for long
    integer multiplication.It's urgent.
    helPlease, Apr 29, 2007
    #1
    1. Advertising

  2. helPlease

    Joe Estock Guest

    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.
    Joe Estock, Apr 29, 2007
    #2
    1. Advertising

  3. helPlease

    Wade Ward Guest

    "Joe Estock" <> wrote in message
    news:...
    > 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
    Wade Ward, Apr 29, 2007
    #3
  4. 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.
    Richard Heathfield, Apr 29, 2007
    #4
  5. 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.
    Richard Heathfield, Apr 29, 2007
    #5
  6. Joe Estock <> writes:
    > 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) <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
    #6
  7. 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;}
    Martin Ambuhl, Apr 29, 2007
    #7
  8. helPlease

    Joe Estock Guest

    Keith Thompson wrote:
    > Joe Estock <> writes:
    >> 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.
    Joe Estock, Apr 29, 2007
    #8
  9. helPlease

    osmium Guest

    "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
    osmium, Apr 29, 2007
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dan Pop
    Replies:
    0
    Views:
    1,167
    Dan Pop
    Jun 24, 2003
  2. cyberdude
    Replies:
    2
    Views:
    5,102
    Keith Thompson
    Jun 25, 2003
  3. helPlease

    long integer multiplication

    helPlease, Apr 30, 2007, in forum: C Programming
    Replies:
    5
    Views:
    373
    Chris Dollin
    Apr 30, 2007
  4. William Hughes
    Replies:
    13
    Views:
    1,200
    Ben Bacarisse
    Mar 15, 2010
  5. Suresh V
    Replies:
    5
    Views:
    3,674
    SaticCaster
    Jul 5, 2010
Loading...

Share This Page