Question:
So for an assignment in my Object Oriented class, we have to create the MyInt class where we allow for storage of large integers. Regardless of
Furthermore, we are to overload nearly all of the operators (+, *, /, -, etc). The + and - and * and / are going to be hard to do because we have to account for carry overs, etc.
So, if I need to store the number
So, my question to you, what would be the best way to store these numbers in the array. Forwards, backwards, reverse, horizontal, etc?
What I want to do, is be able to add, multiply, divide, etc with ease, but I have a hard time beliveing that ease can be used throughout this probject.
We also have the option of storing the values as a character array, a null terminated C style string, however, I felt that wasn't too efficient.
Let's say that I store the number with the first digit at array[0], and the last digit at array[14] if I had a 14 digit number, and had 20 elements dynamically allocated, with a tracking variable. The tracking variable used to keep track of how many numerals are stored in the array. Is there an easy way to count the number of digits in a number. For instance, if I had the number 579, the number of digits is 3.
Eh, this project is going to be hard/tedious/a pain.
Thanks for any help
unsigned int we need to be able to account for storage larger than that. The method that this is to enforce is dynamic memory allocation. Thus, if I need to store a positive integer with 30 decimal places, we are suggested to store each numeral in an elemtn of the array. Weird, I know.Furthermore, we are to overload nearly all of the operators (+, *, /, -, etc). The + and - and * and / are going to be hard to do because we have to account for carry overs, etc.
So, if I need to store the number
8675309123456789, then after passing that number into the constructor that accepts 1 parameter, my array's conects should look like this__________________________________
|8|6|7|5|3|0|9|1|2|3|4|5|6|7|8|9|0
So, my question to you, what would be the best way to store these numbers in the array. Forwards, backwards, reverse, horizontal, etc?
What I want to do, is be able to add, multiply, divide, etc with ease, but I have a hard time beliveing that ease can be used throughout this probject.
We also have the option of storing the values as a character array, a null terminated C style string, however, I felt that wasn't too efficient.
Let's say that I store the number with the first digit at array[0], and the last digit at array[14] if I had a 14 digit number, and had 20 elements dynamically allocated, with a tracking variable. The tracking variable used to keep track of how many numerals are stored in the array. Is there an easy way to count the number of digits in a number. For instance, if I had the number 579, the number of digits is 3.
Eh, this project is going to be hard/tedious/a pain.
Thanks for any help
