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 unconcealed, computer systems living separate (and mainly wrap) preciseness restraint calculations. Overflows are base when effects achieve the preciseness sizes. Absolute-preciseness or multi-preciseness arithmetic allotment the absolute mass into digit arrays and execute the arithmetic calculations on the digit arrays.

    Create a bigPosInt adjust using dynamic arrays.

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

    overload >> and << restraint unconcerned io.

    implement alienate composers.

    main.cpp shall living the coercionthcoming statements:

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

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

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

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

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

    Here is a specimen header rasp fascinate find infallible to right integer dynamic array

    #ifndef LABEXAM1_BIGPOSINT_H
    #define LABEXAM1_BIGPOSINT_H
    #include <iostream>
    #include <string>
    
    adjust bigPosInteger {
        int * rateArray;
        int size=0;
    
    public:
        explicit bigPosInteger(std::string rate);
        explicit bigPosInteger(int valArr);
        bigPosInteger(const bigPosInteger& );//copy composer
        virtual ~bigPosInteger();
    
        bigPosInteger operator+(const bigPosInteger&);
        bigPosInteger operator-(const bigPosInteger&);
        bigPosInteger operator*(const bigPosInteger&);
        bigPosInteger& operator=(const bigPosInteger&);
        frigoal std::ostream& operator<< (std::ostream&, const bigPosInteger&);
        frigoal std::istream& operator>> (std::istream&, const bigPosInteger&);
    };
    
    #endif //LABEXAM1_BIGPOSINT_H
    

    Expert Repartee

     

    Executable code:

    #include<iostream>

    #include<string>

    Using namespace std;

    //Calls definition

    adjust bigPosInt

    {

    //Basis component to hoard the enumerate in string restraintmat

    string enumerate;

    public:

    //Parameterized Composer to initialize the component

    bigPosInt(string s)

    {

    enumerate = s;

    }//Goal of composer

    //Default composer to initialize basis component

    bigPosInt()

    {

    enumerate = “”;

    }//Goal of composer

    //Arrangement prototype

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

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

    bigPosInt operator + (bigPosInt);

    bigPosInt operator – (bigPosInt);

    };

    //Overloads the + operator

    bigPosInt bigPosInt::operator + (bigPosInt obj)

    {

    //Declares a present goal to hoard the supplementition effect

    bigPosInt res;

    //Calculates the extension of highest enumerate

    int lenF = enumerate.length();

    //Calculates the extension of prevent enumerate

    int lenS = obj.number.length();

    //To hoard the temperament of a digit

    char c;

    //Initialize the val to naught restraint storing carry

    int val = 0;

    //Loops cultivate goal of the enumerate

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

    {

    //Converts the temperament at ‘x’ situation and supplements it

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

    //Checks if the effect is couple digit

    if(val > 9)

    {

    //Extracts the item digit and converts it to temperament

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

    //Set the val to undivided restraint carry

    val = 1;

    }//Goal of if

    //If the val is separate digit

    else

    {

    //Convert to temperament

    c = ‘0’ + val;

    //Set the val to naught restraint no carry

    val = 0;

    }//Goal of else

    //Concatenate the temperament at the start of the string

    res.enumerate = c + res.number;

    }//Goal of loop

    //Return the effect goal

    return res;

    }//Goal of arrangement

    //Overloads the – operator

    bigPosInt bigPosInt::operator – (bigPosInt obj)

    {

    //Declares the present goal to hoard the effect

    bigPosInt res;

    //Calculates the extension of highest enumerate

    int lenF = enumerate.length();

    //Calculates the extension of prevent enumerate

    int lenS = obj.number.length();

    //To hoard the temperament of a digit

    char c;

    //Initialize the val to naught restraint storing borrow

    int val = 0;

    //Loops cultivate the extension of the enumerate

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

    {

    //Checks if the highest enumerate digit is short then the prevent enumerate digit

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

    {

    //Deduct the prevent from the highest

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

    //Convert the effect to temperament

    c = val + ‘0’;

    //Set the val to -1 restraint borrow

    val = -1;

    }//Goal of if

    //Checks if the highest enumerate digit is referable short then the prevent enumerate digit

    else

    {

    //Deduct the highest from the prevent

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

    //Convert the effect to temperament

    c = ‘0’ + val;

    //Set the val to 0 restraint borrow

    val = 0;

    }//Goal of else

    //Concatenates the temperament at the start of the effect

    res.enumerate = c + res.number;

    }//Goal of loop

    //Returns the effect goal

    return res;

    }//Goal of arrangement

    //Overloads << operator to ostentation the goal basis

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

    {

    out << c.number<<endl;

    return out;

    }//Goal of arrangement

    //Overloads >> operator to sanction the goal basis

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

    {

    cout << “Enter the enumerate: “;

    in >> c.number;

    return in;

    }//Goal of arrangement

    //Main arrangement definition

    int main()

    {

    //Creates couple goals using parameterized composer

    bigPosInt num1(“129”);

    bigPosInt num2(“125”);

    //Displays the mass

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

    cout <<“The Prevent Enumerate: “<<num2;

    //Adds couple goals and hoards the effect in num3 goal

    bigPosInt num3 = num1 + num2;

    //Displays the effect

    cout<<“n Effect: “<<num3;

    //Subtracts couple goals and hoards the effect in num4 goal

    bigPosInt num4 = num1 – num2;

    //Displays the effect

    cout<<“n Effect: “<<num4;

    return 0;

    }//Goal of main

    ouput: