Question
Ass2 Large Numbers Goals : Understanding operator overloading Design and implement LargeNum class which can be used to represent arbitrarily large numbers and operations on
Ass2 Large Numbers
Goals: Understanding operator overloading
Design and implement LargeNum class which can be used to represent arbitrarily large numbers and operations on them.
Accept the assignment and create your own private GitHub repository with the started code by clicking on this link Links to an external site.. Do not change the repository name or make it public.
largenum.h file is provided for you. You must implement all the public functions that have been defined. main.cpp file includes a series of tests to help guide your design and development.
Design Choices
You have several design choices. Most important choice is how will you store the digits internally. One possibility is using string class. Strings can be as long as needed, provide easy access to each index, have push_back and pop_back functions to expand and shrink as needed.
You may also want to store the digits in reverse order internally so index-0 of two large numbers correspond to the ones unit. For example, storing 12345 and 789 internally as "54321" and "987" means one's digit is at index-0 corresponding to 5 and 9 respectively which will make it easier when adding them.
How do we differentiate between positive and negative numbers? I suggest having a boolean variable, isPositive, that is set to true by default. If the number is negated, the variable can be flipped. The number zero is a special case. We will define zero to be a positive number and make sure it is always treated as a positive number.
I suggest starting the assignment by commenting almost everything and completing the minimum functions necessary for passing test1. Once your program successfully completes test1, you can then proceed to satisfy additional tests. This is similar to test-driven development, but in this case the tests are provided for you.
Grading Criteria
The maximum grade for a program that does not compile and run all the given tests in main.cpp is 50%
Correcteness: 85%
Coding standards: 15% (all functions have comments, clang-format and clang-tidy warnings are addressed or explained in README file, no unnecessary globals, member variables, etc)
Submit:
Before you submit, run create-output.sh script to create output.txt file
The last commit URL for your assignment repository. which will be something like https://github.com/uwbclass/342-P2-githubusername/commit/7e76dd658b0c2fffdec8109d515f15c928beaab0
You can find the last commit URL in your GitHub repository by clicking on, under "commits" > "browse repository".
Tips & Hints
Pay attention to the output from clang-tidy. Fix it if you can, explain how you tried to fix it in the Readme file if you can not fix it.
Correctly format your code. Either set VSC to "format on save" or use "clang-format -i *.cpp". You will unnecessarily lose points if your code is not properly formatted.
Keep your function short. Use helper functions. Use the class functions.
Do NOT include the "cpp" file from another cpp file. You should compile your code using g++ *.cpp, or its equivalent.
Take advantage of the symmetry of mathematical operations, so you do not replicate code when working with negative numbers
-a < -b is the same as a > b
a != b is the same as (!(a == b))
a + -b is the same as a - b
-a + b is the same as b - a
-a + -b is the same as the result of a + b negated
Do not store the "-" sign with the digits. Use a boolean instead to indicate negative values.
You can use == on strings. You do not need to compare them digit by digit
You should never have == true or == false in your conditions. Simplify.
You can do multiplication as repeated addition. Division can be done as repeated subtraction.
You do NOT need to use "new" in this assignment. Do not create any objects on the heap.
You can use stoi on individual digits, but a LargeNum might be too big to use stoi on.
Given a character, you can subtract '0' to turn it into integer.
PreviousNext
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started