C++ Programming Assignment dealing with large integer values -


so assignment have c++ class prove can deal creating classes , operator overloading. have overload functions +, *, +=, *=, ==, !=, <, <=, >, >=, binary function of ^ (hyperint class assignment) have build constructor: () , input output stream, , prefix/postfix. have built header file of these operator overloading:

class hyperint { public: hyperint(void); ~hyperint(void);   const hyperint & operator+= (const hyperint & right); const hyperint & operator*= (const hyperint & right); const hyperint operator^ (long e) const; const hyperint &operator++ (int); const hyperint &operator-- (int);   friend const bool operator== (const hyperint &left, const hyperint &right); friend const bool operator!= (const hyperint &left, const hyperint &right); friend const bool operator< (const hyperint &left, const hyperint &right); friend const bool operator<= (const hyperint &left, const hyperint &right); friend const bool operator> (const hyperint &left, const hyperint &right); friend const bool operator>= (const hyperint &left, const hyperint &right); friend std::istream & operator >> (std::istream & is, hyperint & hypint); friend std::ostream & operator << (std::ostream & os, const hyperint & hypint);    };  const hyperint operator+ (const hyperint & left, const hyperint &right); const hyperint operator* (const hyperint & left, const hyperint &right); 

now i'm having several design issues. because constructor calling type long, type long can handle because long can handle integers from: -2,147,483,647 2,147,483,647, clear value professor wants deal 313^313 cannot held(note: teacher said constructor must accept long variables arguments). question have how can calculate value big, thinking of perhaps converting long string , dealing number way, i'm not sure if appropriate design. or thinking of somehow storing number pieces vector. question design format guys think best suited kind of project? how add 2 hyperint numbers together? lot, appreciated! oh , last quick question, teacher said need have "conversion bool" i'm not entirely sure means this? if have ideas great! again!

what teacher calling hyperint merely arbitrary number of decimal or binary digits. can store many of digits in array or vector, , perform grade school arithmetic on them.

to illustrate, consider following multiplication operation:

        23958233             5830 ×     ------------         00000000 ( =      23,958,233 ×     0)        71874699  ( =      23,958,233 ×    30)      191665864   ( =      23,958,233 ×   800)     119791165    ( =      23,958,233 × 5,000)     ------------     139676498390 ( = 139,676,498,390        ) 

so have 2 operands: 23958233 , 5830. assuming node graph shaped singly-linked list (for illustrative purposes), decimal digits of each operand stored in vector this:

2 --> 3 --> 9 --> 5 --> 8 --> 2 --> 3 --> 3 

and

5 --> 9 --> 8 --> 8 

in other words, each element in vector store single decimal digit, , each vector store single complete number. store intermediate results in similar way (one vector each intermediate result), , add them together, grade-school style.

note illustrates single multiplication operation. raising numbers power, you'll have repeat multiplication many times power says.


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -