Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem: Big Integer Arithmetic This problem asks you to create a custom data type to handle large integer arithmetic, by creating a custom C++ class

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Problem: "Big" Integer Arithmetic This problem asks you to create a custom data type to handle large integer arithmetic, by creating a custom C++ class called BigInt. C++ has a number of types to handle integer data, including ints, short ints and long ints, and their signed and unsigned variants. However, the maximum positive number that one can store in the largest of these, which is an unsigned long int, is 18,446,744,073,709,551,615 This number, as you can see, has 20 digits. In many scientific and engineering applications, this does not suffice to hold values required for complex computations. Anything about 1020 would be too big to hold in the unsigned long int type So your task in this assignment is to create a C++ class called BigInt which will allow basic arithmetic operations on positive integer values of up to 300 digits, storing integers from 0 to 9999...9 (300 9s) The three operations you have to do are addition, subtraction and multiplication. Specific tasks are these: 1. Add two BigInt objects, and store the result in another BigInt, using the operator 2. Add an int to a BigInt object, and store the result in another BigInt, also using the operator 3. Subtract one BigInt object from another, and store the result in another BigInt, using the operator. The second BigInt can always be smaller or equal to the first BigInt. In other words, the results shall never be negative 4. Subtract an int from a BigInt object, and store the result in another BigInt, also using the operator. Should be obvious in this case that the results shall never be negative 5. Multiply two BigInt objects, and store the result in another BigInt, using the operator. The resulting BigInt shall not exceed 300 digits 6. Multiply a BigInt object with an int, and store the result in another BigInt, using the operator Again, the resulting BigInt shall not exceed 300 digits 7. Overload the and operators to input and output BigInt objects to streams, respective Of course, they have to be overloaded as friend functions To start, here's a bare skeleton of the BigInt class. You are welcome to start with this, but do not have to. As a hint, you have to remember your basic school-level arithmetic, and implement this in a C++ class to solve this

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions