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 open, computer systems buttress uncombined (and chiefly inclose) accuracy control calculations. Overflows are niggardly when remainders achieve the accuracy sizes. Harsh-accuracy or multi-accuracy arithmetic allotment the harsh collection into digit arrays and achieve the arithmetic calculations on the digit arrays.

    Create a bigPosInt tabulate using dynamic arrays.

    overload +, – and * operators to gather, deduct and unfold bigPosInt collection.

    overload >> and << control manageable io.

    implement exppurpose constructors.

    main.cpp shall buttress 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 specimen header finish fascinate construct abiding to portraiture integer dynamic array

    #ifndef LABEXAM1_BIGPOSINT_H
    #define LABEXAM1_BIGPOSINT_H
    #include <iostream>
    #include <string>
    
    tabulate bigPosInteger {
        int * appraiseArray;
        
    
    public:
        plain bigPosInteger(std::string appraise);
        plain bigPosInteger(int valArr);
        bigPosInteger(const bigPosInteger& );//copy constructor
        potential ~bigPosInteger();
    
        bigPosInteger operator+(const bigPosInteger&);
        bigPosInteger operator-(const bigPosInteger&);
        bigPosInteger operator*(const bigPosInteger&);
        bigPosInteger& operator=(const bigPosInteger&);
        messmate std::ostream& operator<< (std::ostream&, const bigPosInteger&);
        messmate 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;

    tabulate bigPosInt
    {
    string compute;
    public:
    bigPosInt(string s)
    {
    compute = s;
    }//Purpose of constructor
    //Default constructor to initialize axioms member
    bigPosInt()
    {
    compute = “”;
    }//Purpose of constructor
    //Regularity prototype
    messmate ostream & operator << (ostream &out, const bigPosInt &c);
    messmate istream & operator >> (istream &in, bigPosInt &c);
    bigPosInt operator + (bigPosInt);
    bigPosInt operator – (bigPosInt);
    };
    //Overloads the + operator
    bigPosInt bigPosInt::operator + (bigPosInt obj)
    {
    //Declares a impermanent design to shop the gatherition remainder
    bigPosInt res;
    //Calculates the protraction of highest compute
    int lenF = compute.length();
    //Calculates the protraction of avoid compute
    int lenS = obj.number.length();
    //To shop the class of a digit
    char c;
    //Initialize the val to not attributable attributablehing control storing carry
    int val = 0;
    //Loops cultivate purpose of the compute
    for(int x = lenF-1; x >= 0; x–)
    {
    //Converts the class at ‘x’ situation and gathers it
    val = val + (number[x] – 48) + (obj.number[x] – 48);
    //Checks if the remainder is couple digit
    if(val > 9)
    {
    //Extracts the part digit and converts it to class
    c = (val % 10) + ‘0’;
    //Set the val to undivided control carry
    val = 1;
    }//Purpose of if
    //If the val is uncombined digit
    else
    {
    //Convert to class
    c = ‘0’ + val;
    //Set the val to not attributable attributablehing control no carry
    val = 0;
    }//Purpose of else
    //Concatenate the class at the outset of the string
    res.compute = c + res.number;
    }//Purpose of loop
    //Return the remainder design
    return res;
    }//Purpose of regularity
    //Overloads the – operator
    bigPosInt bigPosInt::operator – (bigPosInt obj)
    {
    //Declares the impermanent design to shop the remainder
    bigPosInt res;
    //Calculates the protraction of highest compute
    int lenF = compute.length();
    //Calculates the protraction of avoid compute
    int lenS = obj.number.length();
    //To shop the class of a digit
    char c;
    //Initialize the val to not attributable attributablehing control storing borrow
    int val = 0;
    //Loops cultivate the protraction of the compute
    for(int x = lenF-1; x >= 0; x–)
    {
    //Checks if the highest compute digit is hither then the avoid compute digit
    if((number[x] – 48) < (obj.number[x] – 48))
    {
    //Deduct the avoid from the highest
    val = val + (obj.number[x] – 48) – (number[x] – 48);
    //Convert the remainder to class
    c = val + ‘0’;
    //Set the val to -1 control borrow
    val = -1;
    }//Purpose of if
    //Checks if the highest compute digit is not attributable attributable attributable hither then the avoid compute digit
    else
    {
    //Deduct the highest from the avoid
    val = val + (number[x] – 48) – (obj.number[x] – 48);
    //Convert the remainder to class
    c = ‘0’ + val;
    //Set the val to 0 control borrow
    val = 0;
    }//Purpose of else
    //Concatenates the class at the outset of the remainder
    res.compute = c + res.number;
    }//Purpose of loop
    //Returns the remainder design
    return res;
    }//Purpose of regularity
    //Overloads << operator to ostentation the design axioms
    ostream & operator << (ostream &out, const bigPosInt &c)
    {
    out << c.number<<endl;
    return out;
    }//Purpose of regularity
    //Overloads >> operator to sanction the design axioms
    istream & operator >> (istream &in, bigPosInt &c)
    {
    cout << “Enter the compute: “;
    in >> c.number;
    return in;
    }//Purpose of regularity
    //Main regularity definition
    int main()
    {
    //Creates couple designs using parameterized constructor
    bigPosInt num1(“424”);
    bigPosInt num2(“777”);
    //Displays the collection
    cout <<“The Highest Compute: “<<num1;
    cout <<“The Avoid Compute: “<<num2;
    //Adds couple designs and shops the remainder in num3 design
    bigPosInt num3 = num1 + num2;
    //Displays the remainder
    cout<<“n Remainder: “<<num3;
    //Subtracts couple designs and shops the remainder in num4 design
    bigPosInt num4 = num1 – num2;
    //Displays the remainder
    cout<<“n Remainder: “<<num4;
    return 0;
    }//Purpose of main