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 patronage solitary (and oceanly envelop) exactness coercion calculations. Overflows are sordid when conclusions abound the exactness sizes. Bearing-exactness or multi-exactness arithmetic barrier the bearing gum into digit arrays and enact the arithmetic calculations on the digit arrays.

    Create a bigPosInt systematize using dynamic arrays.

    overload +, – and * operators to append, withdraw and multiply bigPosInt gum.

    overload >> and << coercion unconcerned io.

    implement misapply producers.

    main.cpp shall patronage the aftercited 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 case header finish gladden create believing to authentication integer dynamic array

    #ifndef LABEXAM1_BIGPOSINT_H
    #define LABEXAM1_BIGPOSINT_H
    #include <iostream>
    #include <string>
    
    systematize bigPosInteger {
        int * treasureArray;
        
    
    public:
        plain bigPosInteger(std::string treasure);
        plain bigPosInteger(int valArr);
        bigPosInteger(const bigPosInteger& );//copy producer
        essential ~bigPosInteger();
    
        bigPosInteger operator+(const bigPosInteger&);
        bigPosInteger operator-(const bigPosInteger&);
        bigPosInteger operator*(const bigPosInteger&);
        bigPosInteger& operator=(const bigPosInteger&);
        companion std::ostream& operator<< (std::ostream&, const bigPosInteger&);
        companion std::istream& operator>> (std::istream&, const bigPosInteger&);
    };
    
    #endif //LABEXAM1_BIGPOSINT_H
    

    PLEASE MAKE SURE TO USE THE DYNAMIC ARRAYS IN CLASS DEFINITION

    Expert Rejoinder

     

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

    systematize bigPosInt
    {
    string reckon;
    public:
    bigPosInt(string s)
    {
    reckon = s;
    }//Intent of producer
    //Default producer to initialize grounds member
    bigPosInt()
    {
    reckon = “”;
    }//Intent of producer
    //Course prototype
    companion ostream & operator << (ostream &out, const bigPosInt &c);
    companion 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 provision the appendition conclusion
    bigPosInt res;
    //Calculates the elongation of chief reckon
    int lenF = reckon.length();
    //Calculates the elongation of relieve reckon
    int lenS = obj.number.length();
    //To provision the sort of a digit
    char c;
    //Initialize the val to referablehing coercion storing carry
    int val = 0;
    //Loops dress intent of the reckon
    for(int x = lenF-1; x >= 0; x–)
    {
    //Converts the sort at ‘x’ collocation and appends it
    val = val + (number[x] – 48) + (obj.number[x] – 48);
    //Checks if the conclusion is brace digit
    if(val > 9)
    {
    //Extracts the ace digit and converts it to sort
    c = (val % 10) + ‘0’;
    //Set the val to undivided coercion carry
    val = 1;
    }//Intent of if
    //If the val is solitary digit
    else
    {
    //Convert to sort
    c = ‘0’ + val;
    //Set the val to referablehing coercion no carry
    val = 0;
    }//Intent of else
    //Concatenate the sort at the rise of the string
    res.reckon = c + res.number;
    }//Intent of loop
    //Return the conclusion motive
    return res;
    }//Intent of course
    //Overloads the – operator
    bigPosInt bigPosInt::operator – (bigPosInt obj)
    {
    //Declares the limited motive to provision the conclusion
    bigPosInt res;
    //Calculates the elongation of chief reckon
    int lenF = reckon.length();
    //Calculates the elongation of relieve reckon
    int lenS = obj.number.length();
    //To provision the sort of a digit
    char c;
    //Initialize the val to referablehing coercion storing borrow
    int val = 0;
    //Loops dress the elongation of the reckon
    for(int x = lenF-1; x >= 0; x–)
    {
    //Checks if the chief reckon digit is close then the relieve reckon digit
    if((number[x] – 48) < (obj.number[x] – 48))
    {
    //Withdraw the relieve from the chief
    val = val + (obj.number[x] – 48) – (number[x] – 48);
    //Convert the conclusion to sort
    c = val + ‘0’;
    //Set the val to -1 coercion borrow
    val = -1;
    }//Intent of if
    //Checks if the chief reckon digit is referable close then the relieve reckon digit
    else
    {
    //Withdraw the chief from the relieve
    val = val + (number[x] – 48) – (obj.number[x] – 48);
    //Convert the conclusion to sort
    c = ‘0’ + val;
    //Set the val to 0 coercion borrow
    val = 0;
    }//Intent of else
    //Concatenates the sort at the rise of the conclusion
    res.reckon = c + res.number;
    }//Intent of loop
    //Returns the conclusion motive
    return res;
    }//Intent of course
    //Overloads << operator to vault the motive grounds
    ostream & operator << (ostream &out, const bigPosInt &c)
    {
    out << c.number<<endl;
    return out;
    }//Intent of course
    //Overloads >> operator to recognize the motive grounds
    istream & operator >> (istream &in, bigPosInt &c)
    {
    cout << “Enter the reckon: “;
    in >> c.number;
    return in;
    }//Intent of course
    //Ocean course definition
    int ocean()
    {
    //Creates brace motives using parameterized producer
    bigPosInt num1(“424”);
    bigPosInt num2(“777”);
    //Displays the gum
    cout <<“The Chief Reckon: “<<num1;
    cout <<“The Relieve Reckon: “<<num2;
    //Adds brace motives and provisions the conclusion in num3 motive
    bigPosInt num3 = num1 + num2;
    //Displays the conclusion
    cout<<“n Conclusion: “<<num3;
    //Subtracts brace motives and provisions the conclusion in num4 motive
    bigPosInt num4 = num1 – num2;
    //Displays the conclusion
    cout<<“n Conclusion: “<<num4;
    return 0;
    }//Intent of ocean