Answered step by step
Verified Expert Solution
Question
1 Approved Answer
We need to create a new class the BigInt class. We will use overloaded operators so that we can perform mathematical calculations that are familiar.
We need to create a new class the BigInt class.
We will use overloaded operators so that we can perform mathematical calculations that are familiar. We will also create some useful functions like fibo which will return the Fibonacci value of that number and fact which will return the factorial.
You can start with this header for the BIgInt class. You may not need all these operators or you may need more. Its up to you. You only need to write the operators that you need to create the solution.
class BigInt
private:
vector v;
BigInt fiboHelperBigInt n BigInt a BigInt b ;
public:
BigInt;
BigIntint;
BigIntstring;
BigInt operatorBigInt;
BigInt operatorBigInt;
BigInt operatorint;
BigInt operatorBigInt;
BigInt operatorBigInt;
BigInt operatorBigInt;
BigInt operatorint;
BigInt operator;
BigInt operatorint; index function
void print;
int size;
BigInt fibo; calls fiboHelper
BigInt fact;
friend ostream& operatorostream& const BigInt&;
friend BigInt operatorint BigInt;
Here are some rules:
You must use vector to store your digits Digits have the numeric value of through never larger they can be larger during calculations
When you use operator to print a BigInt, you will print all digits if the size if or less. If there are more than digits in the BigInt, then you will print in exponential notation to significant digits;
a Example: x
b cout x; output: e
When you use the print function, you will print ALL digits
The fibo function MUST be recursive. I suggest you use tail recursion.
Hints:
a Multiplication is repeated addition
b Division is repeated subtraction
Below is the testUnit function. You are to copy this function into your main program and call it from main. The BigInt class will also be in your main program. The results should look like the output that I have provided:
Here is the testUnit fuction:
void testUnit
int space ;
cout a
TestUnit:
ns"true":"false" before:" before:"s after:" s big big s
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started