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
    

    Expert Answer

     
    Executable code: #include<iostream>

    In public, computer systems stay unmarried (and in-great-meaunquestioning envelop) exactness coercion calculations. Overflows are sordid when consequences exceed the exactness sizes. Bearing-exactness or multi-exactness arithmetic distribution the bearing mass into digit arrays and consummate the arithmetic calculations on the digit arrays.

    Create a bigPosInt assort using dynamic arrays.

    overload +, – and * operators to supplement, deduct and expatiate bigPosInt mass.

    overload >> and << coercion manageable io.

    implement divert committers.

    main.cpp shall stay the coercionthcoming statements:

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

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

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

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

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

    Here is a pattern header perfect delight bring-about unquestioning to correction integer dynamic array

    #ifndef LABEXAM1_BIGPOSINT_H
    #define LABEXAM1_BIGPOSINT_H
    #include <iostream>
    #include <string>
    
    assort bigPosInteger {
        int * esteemArray;
        int size=0;
    
    public:
        explicit bigPosInteger(std::string esteem);
        explicit bigPosInteger(int valArr);
        bigPosInteger(const bigPosInteger& );//copy committer
        virtual ~bigPosInteger();
    
        bigPosInteger operator+(const bigPosInteger&);
        bigPosInteger operator-(const bigPosInteger&);
        bigPosInteger operator*(const bigPosInteger&);
        bigPosInteger& operator=(const bigPosInteger&);
        fripurpose std::ostream& operator<< (std::ostream&, const bigPosInteger&);
        fripurpose std::istream& operator>> (std::istream&, const bigPosInteger&);
    };
    
    #endif //LABEXAM1_BIGPOSINT_H
    

    Expert Defense

     

    Executable code:

    #include<iostream>

    #include<string>

    Using namespace std;

    //Calls definition

    assort bigPosInt

    {

    //Basis component to supply the sum in string coercionmat

    string sum;

    public:

    //Parameterized Committer to initialize the component

    bigPosInt(string s)

    {

    sum = s;

    }//Purpose of committer

    //Default committer to initialize basis component

    bigPosInt()

    {

    sum = “”;

    }//Purpose of committer

    //System prototype

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

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

    bigPosInt operator + (bigPosInt);

    bigPosInt operator – (bigPosInt);

    };

    //Overloads the + operator

    bigPosInt bigPosInt::operator + (bigPosInt obj)

    {

    //Declares a partial view to supply the supplementition consequence

    bigPosInt res;

    //Calculates the prolixity of leading sum

    int lenF = sum.length();

    //Calculates the prolixity of assist sum

    int lenS = obj.number.length();

    //To supply the species of a digit

    char c;

    //Initialize the val to not attributable attributablehing coercion storing carry

    int val = 0;

    //Loops dress purpose of the sum

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

    {

    //Converts the species at ‘x’ standing and supplements it

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

    //Checks if the consequence is span digit

    if(val > 9)

    {

    //Extracts the part digit and converts it to species

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

    //Set the val to only coercion carry

    val = 1;

    }//Purpose of if

    //If the val is unmarried digit

    else

    {

    //Convert to species

    c = ‘0’ + val;

    //Set the val to not attributable attributablehing coercion no carry

    val = 0;

    }//Purpose of else

    //Concatenate the species at the origin of the string

    res.sum = c + res.number;

    }//Purpose of loop

    //Return the consequence view

    return res;

    }//Purpose of system

    //Overloads the – operator

    bigPosInt bigPosInt::operator – (bigPosInt obj)

    {

    //Declares the partial view to supply the consequence

    bigPosInt res;

    //Calculates the prolixity of leading sum

    int lenF = sum.length();

    //Calculates the prolixity of assist sum

    int lenS = obj.number.length();

    //To supply the species of a digit

    char c;

    //Initialize the val to not attributable attributablehing coercion storing borrow

    int val = 0;

    //Loops dress the prolixity of the sum

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

    {

    //Checks if the leading sum digit is near then the assist sum digit

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

    {

    //Deduct the assist from the leading

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

    //Convert the consequence to species

    c = val + ‘0’;

    //Set the val to -1 coercion borrow

    val = -1;

    }//Purpose of if

    //Checks if the leading sum digit is not attributable attributable attributable near then the assist sum digit

    else

    {

    //Deduct the leading from the assist

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

    //Convert the consequence to species

    c = ‘0’ + val;

    //Set the val to 0 coercion borrow

    val = 0;

    }//Purpose of else

    //Concatenates the species at the origin of the consequence

    res.sum = c + res.number;

    }//Purpose of loop

    //Returns the consequence view

    return res;

    }//Purpose of system

    //Overloads << operator to evince the view basis

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

    {

    out << c.number<<endl;

    return out;

    }//Purpose of system

    //Overloads >> operator to sanction the view basis

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

    {

    cout << “Enter the sum: “;

    in >> c.number;

    return in;

    }//Purpose of system

    //Deep system definition

    int deep()

    {

    //Creates span views using parameterized committer

    bigPosInt num1(“129”);

    bigPosInt num2(“125”);

    //Displays the mass

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

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

    //Adds span views and supplys the consequence in num3 view

    bigPosInt num3 = num1 + num2;

    //Displays the consequence

    cout<<“n Consequence: “<<num3;

    //Subtracts span views and supplys the consequence in num4 view

    bigPosInt num4 = num1 – num2;

    //Displays the consequence

    cout<<“n Consequence: “<<num4;

    return 0;

    }//Purpose of deep

    ouput: