# Thread: Very larger integer calulator

1. ## 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 !

2. 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-

3. 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;
};
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) {
}
};
result & add(bool a, bool b, bool carry_in) {