How to perform operations on 200 digit numbers!!!!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Qxx1
    New Member
    • Aug 2010
    • 1

    How to perform operations on 200 digit numbers!!!!

    hello everyone
    i have to code a simple calculator program that performs addition,multip lication,divisi on n substraction operations.
    The operations are to be performed on 200 digit numbers (i.e 2131237287293.. ...upto 200 digits) however multiplication and division can be neglected but i need to perform atleast addition and substraction.
    I am done with the calculator code, but the 200 digit thing is wat i am struck at.
    How to do it?
    wat is big float??is it usefull in my case?
    the program is in C only.
  • newb16
    Contributor
    • Jul 2008
    • 687

    #2
    You are probably expected to implement these long arithmetic operations yourself, without third-party libs. To simplify keyboard input one may choose BCD internal representation, like
    struct longint
    {
    unsigned char digits[200];
    int negative;
    };
    How to add multidigit numbers is something we know from elementary school.

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      The number of digits is irrelevant. What you need to do is define your own number type. Then you write functions that use this number number type.

      Once that's working you can expand the number of digits in your number type.

      One challenge will be initializing your number type with a 200 digit value. That will probably lead you to start using strings for youer numbers:

      Code:
      NUMBER x;
             Assign(x, "1234567"); /
             x = Add(x, "10");  /* add 10 to x */
      There I've written the code for you. All you need do is write those functions.

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        @gprengan90: Please post your solution in this thread.

        Comment

        Working...