A machine with 32-bit integers can represent integers in the range of approximately 2 billion to +2 billion. This fixed-size restriction is rarely troublesome, but there are applications in which we would like to be able to use a much wider range of integers, such as factorial. This is what C++ was built to do, namely, create powerful new data types.
Create class HugeInt that is capable of representing positive (non-negative) 30-digit decimal values (this will be able to represent values from 0 to 1030). The 30-digit number can be represented internally as array of integer whereby each digit takes values from zero to nine. The class must have conversion constructor that convert int or char value to HugeInt. Then overload the following operators
a. Stream insertion (<<) and extraction (>>) operators
b. Arithmetic operators (+,-,/,*). Each operation must also support operation with mix operands (integer and HugeInt objects)
c. Relational operators (==,<=,>=,!=).Each operation must also support operation with mix operands (integer and HugeInt objects)
d. Define a function factorial(X) that calculate factorial of X, whereby X is a HugeInt object.*
The program must follow good programming practices such as information hiding, principle of least privilege, etc.
Your program must compile successfully for the following driver program.
int main()
{
HugeInt a; //HugeInt object initialized to zero
HugeInt b(12345);
HugeInt c(“100200101002005550”);
HugeInt result;
cin >> a;
result = a+b;
cout << a << “+” << b << “ = “ << result << endl;
result = c – b;
cout << result << endl;
result = c / b;
cout << result << endl;
result = c * b;
cout << result << endl;
if (a == b)
cout << “Equal” << endl;
else
cout << “Not Equal” << endl;
if (a >= b)
cout << “Greater” << endl;
else
cout << “Less” << endl;
if (a <= b)
cout << “Less” << endl;
else
cout << “Greater” << endl;
if (a != b)
cout << “Not Equal” << endl;
else
cout << “Equal” << endl;
factorial(b); //will output the result of b factorial
return 0;
}