Boost logo

Boost :

From: christopher diggins (cdiggins_at_[hidden])
Date: 2005-05-24 13:00:58


I just uploaded a very simple arbitrary precision unsigned integer class to
the sandbox ( http://boost-sandbox.sourceforge.net/vault/index.php ).

The class is implemented using naive algorithms and is based on
std::vector<bool>. Efficiency was absolutely not a concern, the priority was
placed on correctness. Without meaning to undermine the impressive work on
the expression template big_integer class I thought perhaps programmers
would generally prefer a more portable and quickly compiled class. The
interface of the type I posted is:

    class big_uint
    {
      typedef big_uint self;
    public:
      big_uint();
      big_uint(const self& x);
      big_uint(const std::vector<bool>& x);
      big_uint(int x);
      self& operator=(const std::vector<bool>& x);
      self& operator<<=(int n);
      self& operator>>=(int n);
      self operator++(int);
      self operator--(int);
      self& operator++();
      self& operator--();
      self& operator+=(const self& x);
      self& operator-=(const self& x);
      self& operator*=(self x);
      self& operator/=(const self& x);
      self& operator%=(const self& x);
      self operator~() const;
      self& operator&=(self x);
      self& operator|=(self x);
      self& operator^=(self x);
      bool operator[](int n) const;
      int size() const;
      unsigned long to_ulong();
      friend self operator<<(const self& x, unsigned int n);
      friend self operator>>(const self& x, unsigned int n);
      friend self operator+(const self& x, const self& y);
      friend self operator-(const self& x, const self& y);
      friend self operator*(const self& x, const self& y);
      friend self operator/(const self& x, const self& y);
      friend self operator%(const self& x, const self& y);
      friend self operator^(const self& x, const self& y);
      friend self operator&(const self& x, const self& y);
      friend self operator|(const self& x, const self& y);
      friend bool operator==(const self& x, const self& y);
      friend bool operator!=(const self& x, const self& y);
      friend bool operator>(const self& x, const self& y);
      friend bool operator<(const self& x, const self& y);
      friend bool operator>=(const self& x, const self& y);
      friend bool operator<=(const self& x, const self& y);
    };

For acceptance into Boost I would guess that this class would have to be
much more efficient (though my view is that something that works is better
than nothing that runs fast). Unfortunately I can not spend any significant
amount of time optimizing it nor doing a proper submission (I would not have
time available until around August), so if someone would like to volunteer
to take it over, I would appreciate it.

Any comments would be most welcome.

--
Christopher Diggins
http://www.cdiggins.com 

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk