Question: #include stdafx.h #include #include #include using namespace std; string big_multiply(string num1, string num2) { int n1 = num1.size(); int n2 = num2.size(); if (n1 ==

#include "stdafx.h"

#include

#include

#include

using namespace std;

string big_multiply(string num1, string num2) { int n1 = num1.size(); int n2 = num2.size(); if (n1 == 0 || n2 == 0) return "0"; vector result(n1 + n2, 0); int i_n1 = 0; int i_n2 = 0; for (int i = n1 - 1; i >= 0; i--) { int carry = 0; int n1 = num1[i] - '0'; i_n2 = 0; for (int j = n2 - 1; j >= 0; j--) { int n2 = num2[j] - '0'; int sum = n1*n2 + result[i_n1 + i_n2] + carry; carry = sum / 10; result[i_n1 + i_n2] = sum % 10; i_n2++; } if (carry > 0) result[i_n1 + i_n2] += carry; i_n1++; } int i = result.size() - 1; while (i >= 0 && result[i] == 0) i--; if (i == -1) return "0"; string s = ""; while (i >= 0) s += std::to_string(result[i--]); return s; } string findSum(string str1, string str2) { if (str1.length() > str2.length()) swap(str1, str2); string str = ""; int n1 = str1.length(), n2 = str2.length(); int diff = n2 - n1; int carry = 0; for (int i = n1 - 1; i >= 0; i--) { int sum = ((str1[i] - '0') + (str2[i + diff] - '0') + carry); str.push_back(sum % 10 + '0'); carry = sum / 10; } for (int i = n2 - n1 - 1; i >= 0; i--) { int sum = ((str2[i] - '0') + carry); str.push_back(sum % 10 + '0'); carry = sum / 10; } if (carry) str.push_back(carry + '0'); reverse(str.begin(), str.end()); return str; } int main() { string big_str1; string big_str2; cout << "Please enter first big integer: " << endl; cin >> big_str1; cout << "Please enter second big integer: " << endl; cin >> big_str2; cout << "The sum of the two numbers is: " << findSum(big_str1, big_str2) << endl; system("pause"); cout << "The mutiplication of the two numbers is: " << big_multiply(big_str1, big_str2) << endl; system("pause"); return 0; }

Consider the class above which enables operations on integers larger than the largest 32 bit integer.

a) Test all capabilities of this class, describe precisely how it operates and what restrictions it has.

b) Overload multiplication * and division / for this class. Overload the relational <, >, assignment and equality == operators for this class.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!