deushiro

h

Oct 30th, 2020
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.05 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <ostream>
  5. #include <istream>
  6.  
  7. #ifndef BIGINTEGER_H
  8. #define BIGINTEGER_H
  9.  
  10. class BigInteger {
  11. public:
  12.   BigInteger(std::string s);
  13.   BigInteger();
  14.   std::string toString();
  15.   BigInteger(int x);
  16.   BigInteger(std::vector<int> &a, bool sign);
  17.  
  18.   BigInteger operator- ();
  19.  
  20.   BigInteger& operator++();
  21.   BigInteger& operator--();
  22.  
  23.   BigInteger operator++(int);
  24.   BigInteger operator--(int);
  25.  
  26.   friend std::ostream& operator<<(std::ostream &os, const BigInteger& num);
  27.   friend std::istream& operator>>(std::istream &is, BigInteger& num);
  28.  
  29.   friend bool operator== (const BigInteger& left, const BigInteger& right);
  30.   friend bool operator!= (const BigInteger& left, const BigInteger& right);
  31.   friend bool operator< (const BigInteger& left, const BigInteger& right);
  32.   friend bool operator> (const BigInteger& left, const BigInteger& right);
  33.   friend bool operator<= (const BigInteger& left, const BigInteger& right);
  34.   friend bool operator>= (const BigInteger& left, const BigInteger& right);
  35.  
  36.   operator bool();
  37.  
  38.   friend BigInteger operator+ (const BigInteger& l, const BigInteger& r);
  39.   friend BigInteger operator- (const BigInteger& l, const BigInteger& r);
  40.   friend BigInteger operator* (const BigInteger& left, const BigInteger& right);
  41.   friend BigInteger operator/ (const BigInteger& dividend, const BigInteger& divisor);
  42.   friend BigInteger operator% (const BigInteger& left, const BigInteger& right);
  43.  
  44.   BigInteger& operator+= (const BigInteger& num);
  45.   BigInteger& operator-= (const BigInteger& num);
  46.   BigInteger& operator*= (const BigInteger& num);
  47.   BigInteger& operator/= (const BigInteger& num);
  48.   BigInteger& operator%= (const BigInteger& num);
  49.  
  50.   static void extend(std::vector<int>&a, int length);
  51.   static std::vector<int> NaiveMultiplication(std::vector<int>& left, std::vector<int>& right);
  52.   static std::vector<int> KaratsubaMultiplication(std::vector<int>&left, std::vector<int>& y);
  53.  
  54. private:
  55.   int length;
  56.   bool positive;
  57.   std::vector<int> number;
  58. };
  59.  
  60. #endif
Advertisement
Add Comment
Please, Sign In to add comment