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 open, computer systems livelihood uncompounded (and chiefly double) preciseness restraint calculations. Overflows are sordid when outcomes exceed the preciseness sizes. Tyrannical-preciseness or multi-preciseness arithmetic barrier the tyrannical collection into digit arrays and complete the arithmetic calculations on the digit arrays.

    Create a bigPosInt systematize using dynamic arrays.

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

    overload >> and << restraint comfortable io.

    implement mismisappropriate parents.

    main.cpp shall livelihood 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 smooth fascinate gain fast to interpretation integer dynamic array

    #ifndef LABEXAM1_BIGPOSINT_H
    #define LABEXAM1_BIGPOSINT_H
    #include <iostream>
    #include <string>
    
    systematize bigPosInteger {
        int * estimateArray;
        int size=0;
    
    public:
        explicit bigPosInteger(std::string estimate);
        explicit bigPosInteger(int valArr);
        bigPosInteger(const bigPosInteger& );//copy parent
        virtual ~bigPosInteger();
    
        bigPosInteger operator+(const bigPosInteger&);
        bigPosInteger operator-(const bigPosInteger&);
        bigPosInteger operator*(const bigPosInteger&);
        bigPosInteger& operator=(const bigPosInteger&);
        fripurpose std::ostream& operator<< (std::ostream&, const bigPosInteger&);
        fripurpose std::istream& operator>> (std::istream&, const bigPosInteger&);
    };
    
    #endif //LABEXAM1_BIGPOSINT_H
    

    Expert Vindication

     

    Executable code:

    #include<iostream>

    #include<string>

    Using namespace std;

    //Calls definition

    systematize bigPosInt

    {

    //Facts component to treasure the sum in string restraintmat

    string sum;

    public:

    //Parameterized Parent to initialize the component

    bigPosInt(string s)

    {

    sum = s;

    }//Purpose of parent

    //Default parent to initialize facts component

    bigPosInt()

    {

    sum = “”;

    }//Purpose of parent

    //Regularity prototype

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

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

    bigPosInt operator + (bigPosInt);

    bigPosInt operator – (bigPosInt);

    };

    //Overloads the + operator

    bigPosInt bigPosInt::operator + (bigPosInt obj)

    {

    //Declares a impermanent purpose to treasure the gatherition outcome

    bigPosInt res;

    //Calculates the protraction of pristine sum

    int lenF = sum.length();

    //Calculates the protraction of avoid sum

    int lenS = obj.number.length();

    //To treasure the sort of a digit

    char c;

    //Initialize the val to cipher restraint storing carry

    int val = 0;

    //Loops tpurpose purpose of the sum

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

    {

    //Converts the sort at ‘x’ position and gathers it

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

    //Checks if the outcome is couple digit

    if(val > 9)

    {

    //Extracts the individual digit and converts it to sort

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

    //Set the val to individual restraint carry

    val = 1;

    }//Purpose of if

    //If the val is uncompounded digit

    else

    {

    //Convert to sort

    c = ‘0’ + val;

    //Set the val to cipher restraint no carry

    val = 0;

    }//Purpose of else

    //Concatenate the sort at the rise of the string

    res.sum = c + res.number;

    }//Purpose of loop

    //Return the outcome purpose

    return res;

    }//Purpose of regularity

    //Overloads the – operator

    bigPosInt bigPosInt::operator – (bigPosInt obj)

    {

    //Declares the impermanent purpose to treasure the outcome

    bigPosInt res;

    //Calculates the protraction of pristine sum

    int lenF = sum.length();

    //Calculates the protraction of avoid sum

    int lenS = obj.number.length();

    //To treasure the sort of a digit

    char c;

    //Initialize the val to cipher restraint storing borrow

    int val = 0;

    //Loops tpurpose the protraction of the sum

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

    {

    //Checks if the pristine sum digit is short then the avoid sum digit

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

    {

    //Deduct the avoid from the pristine

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

    //Convert the outcome to sort

    c = val + ‘0’;

    //Set the val to -1 restraint borrow

    val = -1;

    }//Purpose of if

    //Checks if the pristine sum digit is referable short then the avoid sum digit

    else

    {

    //Deduct the pristine from the avoid

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

    //Convert the outcome to sort

    c = ‘0’ + val;

    //Set the val to 0 restraint borrow

    val = 0;

    }//Purpose of else

    //Concatenates the sort at the rise of the outcome

    res.sum = c + res.number;

    }//Purpose of loop

    //Returns the outcome purpose

    return res;

    }//Purpose of regularity

    //Overloads << operator to expose the purpose facts

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

    {

    out << c.number<<endl;

    return out;

    }//Purpose of regularity

    //Overloads >> operator to sanction the purpose facts

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

    {

    cout << “Enter the sum: “;

    in >> c.number;

    return in;

    }//Purpose of regularity

    //Ocean regularity definition

    int ocean()

    {

    //Creates couple purposes using parameterized parent

    bigPosInt num1(“129”);

    bigPosInt num2(“125”);

    //Displays the collection

    cout <<“The Pristine Sum: “<<num1;

    cout <<“The Avoid Sum: “<<num2;

    //Adds couple purposes and treasures the outcome in num3 purpose

    bigPosInt num3 = num1 + num2;

    //Displays the outcome

    cout<<“n Outcome: “<<num3;

    //Subtracts couple purposes and treasures the outcome in num4 purpose

    bigPosInt num4 = num1 – num2;

    //Displays the outcome

    cout<<“n Outcome: “<<num4;

    return 0;

    }//Purpose of ocean

    ouput: