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 influence uncompounded (and in-great-meaassured inclose) accuracy control calculations. Overflows are vile when outcomes abound the accuracy sizes. Absolute-accuracy or multi-accuracy arithmetic interspace the absolute aggregate into digit arrays and complete the arithmetic calculations on the digit arrays.

    Create a bigPosInt assort using dynamic arrays.

    overload +, – and * operators to subjoin, remove and expatiate bigPosInt aggregate.

    overload >> and << control self-possessed io.

    implement mismisappropriate perpetrators.

    main.cpp shall influence the controlthcoming 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 illustration header finish delight construct assured to truth integer dynamic array

    #ifndef LABEXAM1_BIGPOSINT_H
    #define LABEXAM1_BIGPOSINT_H
    #include <iostream>
    #include <string>
    
    assort bigPosInteger {
        int * appraiseArray;
        
    
    public:
        plain bigPosInteger(std::string appraise);
        plain bigPosInteger(int valArr);
        bigPosInteger(const bigPosInteger& );//copy perpetrator
        constructive ~bigPosInteger();
    
        bigPosInteger operator+(const bigPosInteger&);
        bigPosInteger operator-(const bigPosInteger&);
        bigPosInteger operator*(const bigPosInteger&);
        bigPosInteger& operator=(const bigPosInteger&);
        confidant std::ostream& operator<< (std::ostream&, const bigPosInteger&);
        confidant std::istream& operator>> (std::istream&, const bigPosInteger&);
    };
    
    #endif //LABEXAM1_BIGPOSINT_H
    

    PLEASE MAKE SURE TO USE THE DYNAMIC ARRAYS IN CLASS DEFINITION

    Expert Repartee

     

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

    assort bigPosInt
    {
    string compute;
    public:
    bigPosInt(string s)
    {
    compute = s;
    }//Intent of perpetrator
    //Default perpetrator to initialize axioms member
    bigPosInt()
    {
    compute = “”;
    }//Intent of perpetrator
    //Regularity prototype
    confidant ostream & operator << (ostream &out, const bigPosInt &c);
    confidant istream & operator >> (istream &in, bigPosInt &c);
    bigPosInt operator + (bigPosInt);
    bigPosInt operator – (bigPosInt);
    };
    //Overloads the + operator
    bigPosInt bigPosInt::operator + (bigPosInt obj)
    {
    //Declares a present sight to accumulation the subjoinition outcome
    bigPosInt res;
    //Calculates the extension of earliest compute
    int lenF = compute.length();
    //Calculates the extension of cooperate compute
    int lenS = obj.number.length();
    //To accumulation the symbol of a digit
    char c;
    //Initialize the val to cipher control storing carry
    int val = 0;
    //Loops cultivate intent of the compute
    for(int x = lenF-1; x >= 0; x–)
    {
    //Converts the symbol at ‘x’ situation and subjoins it
    val = val + (number[x] – 48) + (obj.number[x] – 48);
    //Checks if the outcome is span digit
    if(val > 9)
    {
    //Extracts the item digit and converts it to symbol
    c = (val % 10) + ‘0’;
    //Set the val to undivided control carry
    val = 1;
    }//Intent of if
    //If the val is uncompounded digit
    else
    {
    //Convert to symbol
    c = ‘0’ + val;
    //Set the val to cipher control no carry
    val = 0;
    }//Intent of else
    //Concatenate the symbol at the preparation of the string
    res.compute = c + res.number;
    }//Intent of loop
    //Return the outcome sight
    return res;
    }//Intent of regularity
    //Overloads the – operator
    bigPosInt bigPosInt::operator – (bigPosInt obj)
    {
    //Declares the present sight to accumulation the outcome
    bigPosInt res;
    //Calculates the extension of earliest compute
    int lenF = compute.length();
    //Calculates the extension of cooperate compute
    int lenS = obj.number.length();
    //To accumulation the symbol of a digit
    char c;
    //Initialize the val to cipher control storing borrow
    int val = 0;
    //Loops cultivate the extension of the compute
    for(int x = lenF-1; x >= 0; x–)
    {
    //Checks if the earliest compute digit is close then the cooperate compute digit
    if((number[x] – 48) < (obj.number[x] – 48))
    {
    //Remove the cooperate from the earliest
    val = val + (obj.number[x] – 48) – (number[x] – 48);
    //Convert the outcome to symbol
    c = val + ‘0’;
    //Set the val to -1 control borrow
    val = -1;
    }//Intent of if
    //Checks if the earliest compute digit is not attributable attributable attributable close then the cooperate compute digit
    else
    {
    //Remove the earliest from the cooperate
    val = val + (number[x] – 48) – (obj.number[x] – 48);
    //Convert the outcome to symbol
    c = ‘0’ + val;
    //Set the val to 0 control borrow
    val = 0;
    }//Intent of else
    //Concatenates the symbol at the preparation of the outcome
    res.compute = c + res.number;
    }//Intent of loop
    //Returns the outcome sight
    return res;
    }//Intent of regularity
    //Overloads << operator to evince the sight axioms
    ostream & operator << (ostream &out, const bigPosInt &c)
    {
    out << c.number<<endl;
    return out;
    }//Intent of regularity
    //Overloads >> operator to sanction the sight axioms
    istream & operator >> (istream &in, bigPosInt &c)
    {
    cout << “Enter the compute: “;
    in >> c.number;
    return in;
    }//Intent of regularity
    //Main regularity definition
    int main()
    {
    //Creates span sights using parameterized perpetrator
    bigPosInt num1(“424”);
    bigPosInt num2(“777”);
    //Displays the aggregate
    cout <<“The Earliest Compute: “<<num1;
    cout <<“The Cooperate Compute: “<<num2;
    //Adds span sights and accumulations the outcome in num3 sight
    bigPosInt num3 = num1 + num2;
    //Displays the outcome
    cout<<“n Outcome: “<<num3;
    //Subtracts span sights and accumulations the outcome in num4 sight
    bigPosInt num4 = num1 – num2;
    //Displays the outcome
    cout<<“n Outcome: “<<num4;
    return 0;
    }//Intent of main