The native int type in C++ cannot store large integers of more than 10 decimal digits. In this project, you will implement a bigint class that behaves like the int type but can handle unsigned integers of up to 45 digits. 1. You are to build a class named bigint that can deal with up to 45 decimal digits of unsigned integers. The bigint class is specified as follows. 2. The bigint class should have a five-element array (int v[5];) as its private date member. Each element should store 9 decimal digits. For example to store integer 1,300,000,000,000,900,000,000,100,000,000. You should have v[0] = 100000000, v[1] = 900000000, v[2] =0, v[3]= 1300, and v[4] = 0. 3. The bigint class should have the following constructors: bigint(); // default constructor, set the value to be 0 bigint(int x0); // set the value to be x0 bigint(int x0, int x1); // set the value to be x1 ∗ 109 + x0 bigint(int x0, int x1, int x2); // set the value to be x2 ∗ 1018 + x1 ∗ 109 + x0 bigint(int x0, int x1, int x2, int x3); bigint(int x0, int x1, int x2, int x3, int x4); 4. To make bigint behave like int, you must overload the following operators • The extraction operator » for reading a bigint number from an input stream. The input number can have up to 45 digits. Following are two legitimate bigint numbers that can appear as input: 1300000000000900000000100000000 9999999999999999999999999999999999999999999 • The insertion operation « for output a bigint number to an output stream. The number must be output like a regular int number with the first digit being a non zero. • 2 arithmetic operators + and – (*, and / are omitted for this type to simplify the program). • 6 comparison operators <, >, <=, >=, ==, and !=. 5. Once the class is implemented, you can test your implementation using the driver.cpp program. You should also write other driver programs to do a thorough test of your bigint implementation. Put your bigint class declaration in bigint.h and your bigint class implementation in bigint.cpp. Redirect test.txt as the standard input, the output of the program should be identical to ouputt.txt.
The native int type in C++ cannot store large integers of more than 10 decimal digits. In this project, you will implement a bigint class that behaves like the int type but can handle unsigned integers of up to 45 digits.
1. You are to build a class named bigint that can deal with up to 45 decimal digits of unsigned integers. The
bigint class is specified as follows.
2. The bigint class should have a five-element array (int v[5];) as its private date member. Each element
should store 9 decimal digits.
For example to store integer 1,300,000,000,000,900,000,000,100,000,000. You should have v[0] = 100000000,
v[1] = 900000000, v[2] =0, v[3]= 1300, and v[4] = 0.
3. The bigint class should have the following constructors:
bigint(); // default constructor, set the value to be 0
bigint(int x0); // set the value to be x0
bigint(int x0, int x1); // set the value to be x1 ∗ 109 + x0
bigint(int x0, int x1, int x2); // set the value to be x2 ∗ 1018 + x1 ∗ 109 + x0
bigint(int x0, int x1, int x2, int x3);
bigint(int x0, int x1, int x2, int x3, int x4);
4.
To make bigint behave like int, you must overload the following operators
• The extraction operator » for reading a bigint number from an input stream. The input number can
have up to 45 digits. Following are two legitimate bigint numbers that can appear as input:
1300000000000900000000100000000
9999999999999999999999999999999999999999999
• The insertion operation « for output a bigint number to an output stream. The number must be
output like a regular int number with the first digit being a non zero.
• 2 arithmetic operators + and – (*, and / are omitted for this type to simplify the
• 6 comparison operators <, >, <=, >=, ==, and !=.
5. Once the class is implemented, you can test your implementation using the driver.cpp program. You should
also write other driver programs to do a thorough test of your bigint implementation. Put your bigint class
declaration in bigint.h and your bigint class implementation in bigint.cpp. Redirect test.txt as the standard
input, the output of the program should be identical to ouputt.txt.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images