# Homework Solution: In general, computer systems support single (and mostly double) precision for calculations. Overflows are common when res…

In general, computer systems support single (and mostly double) precision for calculations. Overflows are common when results exceed the precision sizes. Arbitrary-precision or multi-precision arithmetic partition the arbitrary numbers into digit arrays and perform the arithmetic calculations on the digit arrays. Create a bigPosInt class using dynamic arrays. overload +, - and * operators to add, subtract and multiply bigPosInt numbers. overload >> and << for easy io. implement appropriate constructors. main.cpp shall support the following statements: bigPosInt num1(“1234567890123456789012345”); bigPosInt num2(“11223344556677889900112233"); ; cin >> num1; cout << “num1: ” << num1 << endl; cout << “num2: ” << num2 << endl; numTest = num1 + num2; cout << “numTest: ” << numTest << endl; numTest = num1 * num2; cout << “numTest: ” << numTest << endl; numTest = num1 - num2; cout << “numTest: ” << numTest << endl; Here is a sample header file please make sure to use integer dynamic array
```#ifndef LABEXAM1_BIGPOSINT_H
#define LABEXAM1_BIGPOSINT_H
#include <iostream>
#include <string>

class bigPosInteger {
int * valueArray;
int size=0;

public:
explicit bigPosInteger(std::string value);
explicit bigPosInteger(int valArr);
bigPosInteger(const bigPosInteger& );//copy constructor
virtual ~bigPosInteger();

bigPosInteger operator+(const bigPosInteger&);
bigPosInteger operator-(const bigPosInteger&);
bigPosInteger operator*(const bigPosInteger&);
bigPosInteger& operator=(const bigPosInteger&);
friend std::ostream& operator<< (std::ostream&, const bigPosInteger&);
friend std::istream& operator>> (std::istream&, const bigPosInteger&);
};

#endif //LABEXAM1_BIGPOSINT_H
```

Executable code: #include<iostream>

In unconcealed, computer systems food separate (and chiefly enfold) exactness restraint calculations. Overflows are niggardly when fruits achieve the exactness sizes. Tyrannical-exactness or multi-exactness arithmetic interspace the tyrannical total into digit arrays and transact the arithmetic calculations on the digit arrays.

Create a bigPosInt systematize using dynamic arrays.

overload +, – and * operators to subjoin, remove and multiply bigPosInt total.

overload >> and << restraint facile io.

implement embezzle creators.

main.cpp shall food the coercionthcoming statements:

bigPosInt num1(“1234567890123456789012345”); bigPosInt num2(“11223344556677889900112233″); ; cin >> num1;

cout << “num1: ” << num1 << intentl; cout << “num2: ” << num2 << intentl;

numTest = num1 + num2; cout << “numTest: ” << numTest << intentl;

numTest = num1 * num2; cout << “numTest: ” << numTest << intentl;

numTest = num1 – num2; cout << “numTest: ” << numTest << intentl;

Here is a scantling header smooth content constitute believing to manifestation integer dynamic array

```#ifndef LABEXAM1_BIGPOSINT_H
#define LABEXAM1_BIGPOSINT_H
#include <iostream>
#include <string>

systematize bigPosInteger {
int * appraiseArray;
int size=0;

public:
explicit bigPosInteger(std::string appraise);
explicit bigPosInteger(int valArr);
bigPosInteger(const bigPosInteger& );//copy creator
virtual ~bigPosInteger();

bigPosInteger operator+(const bigPosInteger&);
bigPosInteger operator-(const bigPosInteger&);
bigPosInteger operator*(const bigPosInteger&);
bigPosInteger& operator=(const bigPosInteger&);
friintent std::ostream& operator<< (std::ostream&, const bigPosInteger&);
friintent std::istream& operator>> (std::istream&, const bigPosInteger&);
};

#endif //LABEXAM1_BIGPOSINT_H
```

## Expert Solution

Executable code:

#include<iostream>

#include<string>

Using namespace std;

//Calls definition

systematize bigPosInt

{

//Basis constituent to shop the sum in string restraintmat

string sum;

public:

//Parameterized Creator to initialize the constituent

bigPosInt(string s)

{

sum = s;

}//Intent of creator

//Default creator to initialize basis constituent

bigPosInt()

{

sum = “”;

}//Intent of creator

//Way prototype

friintent ostream & operator << (ostream &out, const bigPosInt &c);

friintent istream & operator >> (istream &in, bigPosInt &c);

bigPosInt operator + (bigPosInt);

bigPosInt operator – (bigPosInt);

};

bigPosInt bigPosInt::operator + (bigPosInt obj)

{

//Declares a immediate view to shop the subjoinition fruit

bigPosInt res;

//Calculates the tediousness of highest sum

int lenF = sum.length();

//Calculates the tediousness of assist sum

int lenS = obj.number.length();

//To shop the nature of a digit

char c;

//Initialize the val to cipher restraint storing carry

int val = 0;

//Loops dress intent of the sum

for(int x = lenF-1; x >= 0; x–)

{

//Converts the nature at ‘x’ aspect and subjoins it

val = val + (number[x] – 48) + (obj.number[x] – 48);

//Checks if the fruit is span digit

if(val > 9)

{

//Extracts the ace digit and converts it to nature

c = (val % 10) + ‘0’;

//Set the val to undivided restraint carry

val = 1;

}//Intent of if

//If the val is separate digit

else

{

//Convert to nature

c = ‘0’ + val;

//Set the val to cipher restraint no carry

val = 0;

}//Intent of else

//Concatenate the nature at the prelude of the string

res.sum = c + res.number;

}//Intent of loop

//Return the fruit view

return res;

}//Intent of way

bigPosInt bigPosInt::operator – (bigPosInt obj)

{

//Declares the immediate view to shop the fruit

bigPosInt res;

//Calculates the tediousness of highest sum

int lenF = sum.length();

//Calculates the tediousness of assist sum

int lenS = obj.number.length();

//To shop the nature of a digit

char c;

//Initialize the val to cipher restraint storing borrow

int val = 0;

//Loops dress the tediousness of the sum

for(int x = lenF-1; x >= 0; x–)

{

//Checks if the highest sum digit is hither then the assist sum digit

if((number[x] – 48) < (obj.number[x] – 48))

{

//Remove the assist from the highest

val = val + (obj.number[x] – 48) – (number[x] – 48);

//Convert the fruit to nature

c = val + ‘0’;

//Set the val to -1 restraint borrow

val = -1;

}//Intent of if

//Checks if the highest sum digit is not attributable attributable attributable hither then the assist sum digit

else

{

//Remove the highest from the assist

val = val + (number[x] – 48) – (obj.number[x] – 48);

//Convert the fruit to nature

c = ‘0’ + val;

//Set the val to 0 restraint borrow

val = 0;

}//Intent of else

//Concatenates the nature at the prelude of the fruit

res.sum = c + res.number;

}//Intent of loop

//Returns the fruit view

return res;

}//Intent of way

//Overloads << operator to flaunt the view basis

ostream & operator << (ostream &out, const bigPosInt &c)

{

out << c.number<<endl;

return out;

}//Intent of way

//Overloads >> operator to confirm the view basis

istream & operator >> (istream &in, bigPosInt &c)

{

cout << “Enter the sum: “;

in >> c.number;

return in;

}//Intent of way

//Deep way definition

int deep()

{

//Creates span views using parameterized creator

bigPosInt num1(“129”);

bigPosInt num2(“125”);

//Displays the total

cout <<“The Highest Sum: “<<num1;

cout <<“The Assist Sum: “<<num2;

//Adds span views and shops the fruit in num3 view

bigPosInt num3 = num1 + num2;

//Displays the fruit

cout<<“n Fruit: “<<num3;

//Subtracts span views and shops the fruit in num4 view

bigPosInt num4 = num1 – num2;

//Displays the fruit

cout<<“n Fruit: “<<num4;

return 0;

}//Intent of deep

ouput: