# Very larger integer calulator

• 09-14-2004
Dewayne
Very larger integer calulator
I have to write a C++ program to add,multiply, and divide very large integer numbers of unlimited size. The book suggest breaking the number up like this 9876543210987654 =
987 765 432 109 876 54 ..... and handling it like that I am totally lost on how to do this please help !
• 09-14-2004
Codulation
Search Google for big int class and you will get lots of pre-written classes that overload the operators. You can look at these to see where to start. Basically you can store a num of any length in a string and write functions to do the math on them, all wrapped inside a class with the usual overloaded ops.
-d-
• 09-14-2004
Sebastiani
most mathematical operations of a computer involve addition on some level - subtraction becomes the addition of numbers in two's complement, multiplication repetitive addition, and division repetitive subtraction. here's a small set of classes that add binary bits just like a computer:

Code:

```namespace adder {  struct result {   result & set(bool _sum, bool _carry) {   sum = _sum, carry = _carry;   return *this;   }   void clear(void) {   set(0, 0);   }   result(bool _sum = 0, bool _carry = 0) {   set(_sum, _carry);   }   bool sum, carry;  };  struct halfadder : result {   result & add(bool a, bool b) {   sum = xor_gate(a, b);   carry = and_gate(a, b);   return *this;   }   halfadder(bool a = 0, bool b = 0) {   add(a, b);   }  };  struct fulladder : halfadder {   result & add(bool a, bool b, bool carry_in) {   halfadder first(a, b);   halfadder::add(carry_in, first.sum);   carry = or_gate(carry, first.carry);   return *this;   }   fulladder(bool a = 0, bool b = 0, bool carry_in = 0) {   add(a, b, carry_in);   }  }; } // namespace adder```
good luck!