very very very long integer

Discussion in 'C Programming' started by Abhishek Jha, Oct 16, 2004.

  1. Abhishek Jha

    Abhishek Jha Guest

    You can implement very very long integer using strings. Strings have
    no limit and using your own code implementation you can store the
    numbers of as much length as you want..........for more details
    contact at
     
    Abhishek Jha, Oct 16, 2004
    #1
    1. Advertising

  2. Abhishek Jha wrote:
    > You can implement very very long integer using strings. Strings have
    > no limit and using your own code implementation you can store the
    > numbers of as much length as you want..........for more details
    > contact at


    But how would u perform the arithmetic operations
    if you are storing them as strings.

    --
    Karthik. http://akktech.blogspot.com .
    ' Remove _nospamplz from my email to mail me. '
     
    Karthik Kumar, Oct 16, 2004
    #2
    1. Advertising

  3. Abhishek Jha

    jacob navia Guest

    Karthik Kumar wrote:
    > Abhishek Jha wrote:
    >
    >> You can implement very very long integer using strings. Strings have
    >> no limit and using your own code implementation you can store the
    >> numbers of as much length as you want..........for more details
    >> contact at

    >
    >
    > But how would u perform the arithmetic operations
    > if you are storing them as strings.
    >

    You can do that without any problems:
    "12345"
    +
    "12345"

    Start at the end:
    Carry = 0

    loop:
    ('5' - '0') + ('5' - '0') ==> result 10

    write Carry + '0' + result%10 to output string.

    Carry = result/10,

    goto loop;

    Some bignums libraries use this representation.
     
    jacob navia, Oct 16, 2004
    #3
  4. jacob navia wrote:
    > Karthik Kumar wrote:
    >
    >> Abhishek Jha wrote:
    >>
    >>> You can implement very very long integer using strings. Strings have
    >>> no limit and using your own code implementation you can store the
    >>> numbers of as much length as you want..........for more details
    >>> contact at

    >>
    >>
    >>
    >> But how would u perform the arithmetic operations
    >> if you are storing them as strings.
    >>

    > You can do that without any problems:
    > "12345"
    > +
    > "12345"
    >
    > Start at the end:
    > Carry = 0
    >
    > loop:
    > ('5' - '0') + ('5' - '0') ==> result 10
    >
    > write Carry + '0' + result%10 to output string.
    >
    > Carry = result/10,
    >
    > goto loop;
    >
    > Some bignums libraries use this representation.
    >
    >

    Apparently that seems less efficient in terms of computation
    complexity compared to a linked list. The reason is here -
    at any given time, we are processing one digit. Whereas when represented
    as long, we can process a good number of digits at any given time , more
    than 1.

    --
    Karthik. http://akktech.blogspot.com .
    ' Remove _nospamplz from my email to mail me. '
     
    Karthik Kumar, Oct 17, 2004
    #4
  5. Abhishek Jha

    jacob navia Guest

    Karthik Kumar wrote:
    > jacob navia wrote:
    >
    >> Karthik Kumar wrote:
    >>

    > Apparently that seems less efficient in terms of computation
    > complexity compared to a linked list. The reason is here -
    > at any given time, we are processing one digit. Whereas when represented
    > as long, we can process a good number of digits at any given time , more
    > than 1.
    >


    Yes. But it is easier to handle than binary, and binary-->decimals
    conversions are very cheap... nothing needs to be done.
     
    jacob navia, Oct 17, 2004
    #5
    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,191
    Dan Pop
    Jun 24, 2003
  2. cyberdude
    Replies:
    2
    Views:
    5,145
    Keith Thompson
    Jun 25, 2003
  3. music4
    Replies:
    3
    Views:
    933
    CBFalconer
    Jan 5, 2004
  4. shanx__=|;-

    very very very long integer

    shanx__=|;-, Oct 16, 2004, in forum: C Programming
    Replies:
    19
    Views:
    1,675
    Merrill & Michele
    Oct 19, 2004
  5. Suresh V
    Replies:
    5
    Views:
    3,772
    SaticCaster
    Jul 5, 2010
Loading...

Share This Page