Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- friend std::ostream& operator<< (std::ostream &o, const double_uint &x)
- {
- return o << std::string(x);
- }
- double_uint& operator= (int x)
- {
- lo_ = x;
- hi_ = T();
- return *this;
- }
- double_uint& operator=(const double_uint &u)
- {
- lo_ = u.lo_;
- hi_ = u.hi_;
- return *this;
- }
- operator T() const {return lo_;}
- operator T() {return lo_;}
- operator const std::string() const {return tostring();}
- operator std::string() {return tostring();
- }
- double_uint operator+= (const double_uint &u)
- {
- T old = lo_;
- lo_ += u.lo_;
- if (lo_ < old) hi_++;
- hi_ += u.hi_;
- return *this;
- }
- double_uint operator-= (const double_uint &u)
- {
- T old = lo_;
- lo_ -= u.lo_;
- if (lo_ > old) hi_--;
- hi_ -= u.lo_;
- return *this;
- }
- double_uint operator+ (const double_uint &u) const
- {
- double_uint res(*this);
- return res += u;
- }
- double_uint operator- (const double_uint &u) const
- {
- double_uint res(*this);
- return res -= u;
- }
- double_uint operator++ (void)
- {
- return *this += double_uint(1);
- }
- double_uint operator++ (int)
- {
- double_uint res(*this);
- *this += double_uint(0, 1);
- return res;
- }
- double_uint operator- (void)
- {
- return double_uint(0) - *this;
- }
- double_uint operator+ (void) const
- {
- return *this;
- }
- double_uint operator<<= (int x)
- {
- x &= (tsize - 1);
- if (x >= hsize)
- {
- hi_ = lo_ << (x - hsize);
- lo_ = 0;
- return *this;
- }
- hi_ <<= x;
- hi_ += lo_ >> (hsize - x);
- lo_ <<= x;
- return *this;
- }
- double_uint operator>>= (int x)
- {
- x &= (tsize - 1);
- if (x >= hsize)
- {
- lo_ = hi_ >> (x - hsize);
- hi_ = 0;
- return *this;
- }
- lo_ >>= x;
- lo_ += hi_ << (hsize - x);
- hi_ >>= x;
- return *this;
- }
- double_uint operator<< (int x) const
- {
- double_uint res(*this);
- return res <<= x;
- }
- double_uint operator>> (int x) const
- {
- double_uint res(*this);
- return res >>= x;
- }
Add Comment
Please, Sign In to add comment