You know OP, if you want to just handle much larger numbers, then make your own class. In the class define how you add, subtract, multiply, divide, error check, remove leading zeros, etc., with functions.
Then overload operators such as =, +, -, *, /, %, +=, =+, *=, /=, %=, etc., so you can use your class like an
int
(you can even define how the bit wise operations are done and overload operators for them). The only difference for large numbers would be something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
// necessary standard libraries...
// your large number class
class large_number
{
// implementation large number handling
}
int main(int argc, char *argv[])
{
large_number x;
// overlord assignment operator
x = "12345678901234567890123456789"; // assign/initialize using a string
std::cout << x << '\n'; // in the class define a friend function that overloads the << operator to print
return 0;
}
|
The difference would be that you would probably have to use strings to handle the large numbers. Assigning, adding, initializing, etc., would be done using strings (you could convert them into integral types if they are small enough_.