Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. #ifndef BIGINT_BIG_INTEGER_H
  2. #define BIGINT_BIG_INTEGER_H
  3.  
  4. #include <string>
  5. #include "my_vec.h"
  6.  
  7. class big_integer {
  8. public:
  9. big_integer() : data(1), sign(true) {}
  10. big_integer(int a);
  11. explicit big_integer(std::string const &str);
  12. big_integer(big_integer const &other) : data(other.data), sign(other.sign) {}
  13. ~big_integer();
  14.  
  15. big_integer &operator=(big_integer const &other);
  16. big_integer &operator+=(big_integer const &rhs);
  17. big_integer &operator-=(big_integer const &rhs);
  18. big_integer &operator*=(big_integer const &rhs);
  19. big_integer &operator/=(big_integer const &rhs);
  20. big_integer &operator%=(big_integer const &rhs);
  21. big_integer &operator&=(big_integer const &rhs);
  22. big_integer &operator|=(big_integer const &rhs);
  23. big_integer &operator^=(big_integer const &rhs);
  24. big_integer &operator<<=(int rhs);
  25. big_integer &operator>>=(int rhs);
  26.  
  27. big_integer operator+() const;
  28. big_integer operator-() const;
  29. big_integer operator~() const;
  30. big_integer &operator++();
  31. big_integer operator++(int);
  32. big_integer &operator--();
  33. big_integer operator--(int);
  34.  
  35. friend bool operator==(big_integer const &a, big_integer const &b);
  36. friend bool operator!=(big_integer const &a, big_integer const &b);
  37. friend bool operator<(big_integer const &a, big_integer const &b);
  38. friend bool operator>(big_integer const &a, big_integer const &b);
  39. friend bool operator<=(big_integer const &a, big_integer const &b);
  40. friend bool operator>=(big_integer const &a, big_integer const &b);
  41.  
  42. friend std::string to_string(big_integer const &a);
  43.  
  44. private:
  45. my_vec data;
  46. bool sign;
  47. const static uint64_t BASE = static_cast<uint64_t>(UINT32_MAX) + 1;
  48. const int basepow = 32;
  49.  
  50. inline void flip_bytes(big_integer &a);
  51. inline void make_zero();
  52. inline void remove_leading_zeros();
  53. big_integer &abstract_operation(big_integer &a, big_integer b, uint32_t(*logicFunc)(uint32_t, uint32_t), bool(*check)(bool, bool));
  54. big_integer mul(big_integer const &b, uint32_t x);
  55. int compare_abs(big_integer const& a, big_integer const& b);
  56. };
  57.  
  58. big_integer operator+(big_integer a, big_integer const &b);
  59. big_integer operator-(big_integer a, big_integer const &b);
  60. big_integer operator*(big_integer a, big_integer const &b);
  61. big_integer operator/(big_integer a, big_integer const &b);
  62. big_integer operator%(big_integer a, big_integer const &b);
  63. big_integer operator&(big_integer a, big_integer const &b);
  64. big_integer operator|(big_integer a, big_integer const &b);
  65. big_integer operator^(big_integer a, big_integer const &b);
  66. big_integer operator<<(big_integer a, int b);
  67. big_integer operator>>(big_integer a, int b);
  68. bool operator==(big_integer const &a, big_integer const &b);
  69. bool operator!=(big_integer const &a, big_integer const &b);
  70. bool operator<(big_integer const &a, big_integer const &b);
  71. bool operator>(big_integer const &a, big_integer const &b);
  72. bool operator<=(big_integer const &a, big_integer const &b);
  73. bool operator>=(big_integer const &a, big_integer const &b);
  74.  
  75. std::string to_string(big_integer const &a);
  76. std::ostream &operator<<(std::ostream &s, big_integer const &a);
  77.  
  78. #endif //BIGINT_BIG_INTEGER_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement