1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

multiplying a bignumber

Discussion in 'C' started by altafahmed2k4, Dec 29, 2006.

  1. altafahmed2k4

    altafahmed2k4 New Member

    Joined:
    Aug 26, 2006
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    Task is
    >>I should create a way to get a bignumber ie >2^16 for Turboc using as a string
    and store it in a binary format (integer).
    >>The number should be reusable
     
  2. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,646
    Likes Received:
    86
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    Integers can't hold numbers big like 2^16.
     
  3. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    [​IMG]

    Depends on how your integer is defined. Mine are 32-bit (with a provision for an int64). 2^16 is a mere drop in the bucket. If your implementation can only deal with 16-bit integers, then you have to take on the task of chaining them together, yourself. You do it every day when you operate on decimal numbers using pencil and paper.
     
    Last edited: Dec 29, 2006
  4. altafahmed2k4

    altafahmed2k4 New Member

    Joined:
    Aug 26, 2006
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    thank u all i know about 2^16 but

    one thing
    >>i have to enter a big number as a string and that number should be accepted as any normal number and it should be stored as array for eg
    if number is 65536

    then a[0]=0
    a[1]=1

    now i think i have made it clear can any one help me
     
  5. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    If you're using one array element for each binary digit, then you need an array for each operand. You then work with the individual elements of those arrays in the same way that the ALU in your uP works with individual bits.

    To begin with, you're going to have to know how to implement a full-adder. It's just an exclusive-or with carry. Once you can add, you can subtract (think two's complement). Once you can add and subtract, you can multiply and divide.

    I suspect they are teaching you how a uP works, so you might want to begin by studying that, binary arithmetic, etc.
     

Share This Page