multiplication

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

  1. helPlease

    helPlease Guest

    I want to multiply two very long integers (say of 20 digits).I am
    storing them in character array.Then what mechanism should i follow
    to mutiply two such numbers.If anybody has any suggestions please post.
     
    helPlease, Apr 30, 2007
    #1
    1. Advertising

  2. On 30 Apr 2007 04:29:26 -0700, helPlease <>
    wrote:

    >I want to multiply two very long integers (say of 20 digits).I am
    >storing them in character array.Then what mechanism should i follow
    >to mutiply two such numbers.If anybody has any suggestions please post.


    Take a pencil and paper and multiply two four-digit numbers. Carefully
    show **every** step. Notice that while the total number of steps is
    dependent on the number of digits in the two numbers, each individual
    step is dependent only on one digit from each number (and any
    potential carry from the previous step).

    As a preliminary step to multiplying, work out the algorithm to add
    two numbers of arbitrary length. Then implement the algorithm in a
    function and test extensively. Notice that the sum of two n-digit
    numbers has at most n+1 digits.

    Follow the same process for multiplication. Since you will need to do
    some addition, make use of the function previously developed. Notice
    that the product of two n-digit numbers can have up to 2n digits.

    If/when you run into problems, post your code and ask specific
    questions. Here is a starting hint. Decide if the elements of your
    character array will contain the integer value or the character value
    of the digits, '1' is not the same as 1. One simplifies input/output;
    the other simplifies computation.

    And please don't post the same question multiple times with different
    subjects.


    Remove del for email
     
    Barry Schwarz, Apr 30, 2007
    #2
    1. Advertising

  3. helPlease

    user923005 Guest

    On Apr 30, 4:29 am, helPlease <> wrote:
    > I want to multiply two very long integers (say of 20 digits).I am
    > storing them in character array.Then what mechanism should i follow
    > to mutiply two such numbers.If anybody has any suggestions please post.


    For only 20 digits, schoolbook method will be fine.
    If you need bigger numbers, then try news:sci.crypt where they talk
    about that sort of thing all day long.
     
    user923005, Apr 30, 2007
    #3
    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. walala
    Replies:
    2
    Views:
    2,359
    joris
    Mar 24, 2010
  2. Patrick
    Replies:
    1
    Views:
    1,253
    Jerzy
    Nov 30, 2004
  3. Nisheeth

    multiplication prob

    Nisheeth, Mar 31, 2005, in forum: VHDL
    Replies:
    1
    Views:
    648
    Jonathan Bromley
    Mar 31, 2005
  4. Weng Tianxiang
    Replies:
    4
    Views:
    3,151
    Weng Tianxiang
    Apr 7, 2005
  5. William Hughes
    Replies:
    13
    Views:
    1,285
    Ben Bacarisse
    Mar 15, 2010
Loading...

Share This Page