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

    Q: 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;
        
    
    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
    
    PLEASE MAKE SURE TO USE THE DYNAMIC ARRAYS IN CLASS DEFINITION

    Expert Answer

     
    #include<iostream> #include<string>

    Q:

    In unconcealed, computer systems food sole (and in-great-meapositive inclose) accuracy restraint calculations. Overflows are dishonorable when outcomes achieve the accuracy sizes. Domineering-accuracy or multi-accuracy arithmetic interspace the domineering aggregate into digit arrays and transact the arithmetic calculations on the digit arrays.

    Create a bigPosInt arrange using dynamic arrays.

    overload +, – and * operators to supplement, remove and unfold bigPosInt aggregate.

    overload >> and << restraint quiet io.

    implement misapply makers.

    main.cpp shall food the aftercited 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 scantling header polish delight find positive to portraiture integer dynamic array

    #ifndef LABEXAM1_BIGPOSINT_H
    #define LABEXAM1_BIGPOSINT_H
    #include <iostream>
    #include <string>
    
    arrange bigPosInteger {
        int * esteemArray;
        
    
    public:
        self-evident bigPosInteger(std::string esteem);
        self-evident bigPosInteger(int valArr);
        bigPosInteger(const bigPosInteger& );//copy maker
        essential ~bigPosInteger();
    
        bigPosInteger operator+(const bigPosInteger&);
        bigPosInteger operator-(const bigPosInteger&);
        bigPosInteger operator*(const bigPosInteger&);
        bigPosInteger& operator=(const bigPosInteger&);
        chum std::ostream& operator<< (std::ostream&, const bigPosInteger&);
        chum std::istream& operator>> (std::istream&, const bigPosInteger&);
    };
    
    #endif //LABEXAM1_BIGPOSINT_H
    

    PLEASE MAKE SURE TO USE THE DYNAMIC ARRAYS IN CLASS DEFINITION

    Expert Solution

     

    #include<iostream>
    #include<string>
    using namespace std;

    arrange bigPosInt
    {
    string reckon;
    public:
    bigPosInt(string s)
    {
    reckon = s;
    }//Purpose of maker
    //Default maker to initialize axioms member
    bigPosInt()
    {
    reckon = “”;
    }//Purpose of maker
    //Rule prototype
    chum ostream & operator << (ostream &out, const bigPosInt &c);
    chum istream & operator >> (istream &in, bigPosInt &c);
    bigPosInt operator + (bigPosInt);
    bigPosInt operator – (bigPosInt);
    };
    //Overloads the + operator
    bigPosInt bigPosInt::operator + (bigPosInt obj)
    {
    //Declares a limited motive to place-of-business the supplementition outcome
    bigPosInt res;
    //Calculates the diffusiveness of coercionemost reckon
    int lenF = reckon.length();
    //Calculates the diffusiveness of relieve reckon
    int lenS = obj.number.length();
    //To place-of-business the capacity of a digit
    char c;
    //Initialize the val to referablehing restraint storing carry
    int val = 0;
    //Loops dress purpose of the reckon
    for(int x = lenF-1; x >= 0; x–)
    {
    //Converts the capacity at ‘x’ standing and supplements it
    val = val + (number[x] – 48) + (obj.number[x] – 48);
    //Checks if the outcome is couple digit
    if(val > 9)
    {
    //Extracts the ace digit and converts it to capacity
    c = (val % 10) + ‘0’;
    //Set the val to undivided restraint carry
    val = 1;
    }//Purpose of if
    //If the val is sole digit
    else
    {
    //Convert to capacity
    c = ‘0’ + val;
    //Set the val to referablehing restraint no carry
    val = 0;
    }//Purpose of else
    //Concatenate the capacity at the threshold of the string
    res.reckon = c + res.number;
    }//Purpose of loop
    //Return the outcome motive
    return res;
    }//Purpose of rule
    //Overloads the – operator
    bigPosInt bigPosInt::operator – (bigPosInt obj)
    {
    //Declares the limited motive to place-of-business the outcome
    bigPosInt res;
    //Calculates the diffusiveness of coercionemost reckon
    int lenF = reckon.length();
    //Calculates the diffusiveness of relieve reckon
    int lenS = obj.number.length();
    //To place-of-business the capacity of a digit
    char c;
    //Initialize the val to referablehing restraint storing borrow
    int val = 0;
    //Loops dress the diffusiveness of the reckon
    for(int x = lenF-1; x >= 0; x–)
    {
    //Checks if the coercionemost reckon digit is less then the relieve reckon digit
    if((number[x] – 48) < (obj.number[x] – 48))
    {
    //Remove the relieve from the coercionemost
    val = val + (obj.number[x] – 48) – (number[x] – 48);
    //Convert the outcome to capacity
    c = val + ‘0’;
    //Set the val to -1 restraint borrow
    val = -1;
    }//Purpose of if
    //Checks if the coercionemost reckon digit is referable less then the relieve reckon digit
    else
    {
    //Remove the coercionemost from the relieve
    val = val + (number[x] – 48) – (obj.number[x] – 48);
    //Convert the outcome to capacity
    c = ‘0’ + val;
    //Set the val to 0 restraint borrow
    val = 0;
    }//Purpose of else
    //Concatenates the capacity at the threshold of the outcome
    res.reckon = c + res.number;
    }//Purpose of loop
    //Returns the outcome motive
    return res;
    }//Purpose of rule
    //Overloads << operator to unfold the motive axioms
    ostream & operator << (ostream &out, const bigPosInt &c)
    {
    out << c.number<<endl;
    return out;
    }//Purpose of rule
    //Overloads >> operator to recognize the motive axioms
    istream & operator >> (istream &in, bigPosInt &c)
    {
    cout << “Enter the reckon: “;
    in >> c.number;
    return in;
    }//Purpose of rule
    //Main rule definition
    int main()
    {
    //Creates couple motives using parameterized maker
    bigPosInt num1(“424”);
    bigPosInt num2(“777”);
    //Displays the aggregate
    cout <<“The Coercionemost Reckon: “<<num1;
    cout <<“The Relieve Reckon: “<<num2;
    //Adds couple motives and place-of-businesss the outcome in num3 motive
    bigPosInt num3 = num1 + num2;
    //Displays the outcome
    cout<<“n Outcome: “<<num3;
    //Subtracts couple motives and place-of-businesss the outcome in num4 motive
    bigPosInt num4 = num1 – num2;
    //Displays the outcome
    cout<<“n Outcome: “<<num4;
    return 0;
    }//Purpose of main